70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Data.SqlClient;
|
|
using CommonLib;
|
|
using CommonLib.data;
|
|
|
|
namespace EmployeeManager
|
|
{
|
|
public partial class FrmMain : FormBase
|
|
{
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private SqlDataAdapter da;
|
|
private DataSet ds = new DataSet();
|
|
private void FrmMain_Load(object sender, EventArgs e)
|
|
{
|
|
da = SqlHelper.ExecuteAdapter(CommandType.Text, "select EmployeeId,EmployeeName,Sex from p_Employeetab");
|
|
LoadData();
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
try
|
|
{
|
|
//DataSet ds = SqlHelper.ExecuteDataSet(CommandType.Text, "select EmployeeId,EmployeeName,Sex from p_Employeetab", "p_Employeetab", null);
|
|
//dataGridView1.DataSource = ds.Tables[0];
|
|
ds.Tables.Clear();
|
|
da.Fill(ds);//, "p_Employeetab");
|
|
dataGridView1.DataSource = ds.Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(da);
|
|
da.Update(ds);
|
|
LoadData();
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
FrmTest f = new FrmTest();
|
|
f.ShowDialog();
|
|
f.Dispose();
|
|
}
|
|
|
|
private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |