?? amendstafferinfo.cs
字號(hào):
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@籍貫", System.Data.SqlDbType.VarChar, 50, "籍貫"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@民族", System.Data.SqlDbType.VarChar, 20, "民族"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@文化程度", System.Data.SqlDbType.VarChar, 50, "文化程度"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@畢業(yè)學(xué)校", System.Data.SqlDbType.VarChar, 100, "畢業(yè)學(xué)校"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@健康狀況", System.Data.SqlDbType.VarChar, 50, "健康狀況"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@婚姻狀況", System.Data.SqlDbType.VarChar, 10, "婚姻狀況"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@身份證號(hào)碼", System.Data.SqlDbType.VarChar, 18, "身份證號(hào)碼"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@家庭電話", System.Data.SqlDbType.VarChar, 50, "家庭電話"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@辦公電話", System.Data.SqlDbType.VarChar, 50, "辦公電話"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@手機(jī)", System.Data.SqlDbType.VarChar, 50, "手機(jī)"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@電子郵件地址", System.Data.SqlDbType.VarChar, 50, "電子郵件地址"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@職工賬號(hào)", System.Data.SqlDbType.VarChar, 20, "職工賬號(hào)"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@單位編號(hào)", System.Data.SqlDbType.VarChar, 20, "單位編號(hào)"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@備注", System.Data.SqlDbType.VarChar, 100, "備注"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_職員編號(hào)", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "職員編號(hào)", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_健康狀況", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "健康狀況", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出生日期", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出生日期", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_辦公電話", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "辦公電話", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_單位編號(hào)", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "單位編號(hào)", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_備注", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "備注", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名簡碼", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名簡碼", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_婚姻狀況", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "婚姻狀況", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_家庭電話", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "家庭電話", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_年齡", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "年齡", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性別", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性別", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_手機(jī)", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "手機(jī)", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_文化程度", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "文化程度", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_畢業(yè)學(xué)校", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "畢業(yè)學(xué)校", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_民族", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "民族", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_電子郵件地址", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "電子郵件地址", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_籍貫", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "籍貫", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_職工賬號(hào)", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "職工賬號(hào)", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_身份證號(hào)碼", System.Data.SqlDbType.VarChar, 18, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "身份證號(hào)碼", System.Data.DataRowVersion.Original, null));
//
// AmendStafferInfo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(642, 469);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.toolBar1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "AmendStafferInfo";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "【職員信息維護(hù)】";
this.Load += new System.EventHandler(this.AmendStafferInfo_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
//--------------------初始化窗體,讀入數(shù)據(jù)------------------
private void AmendStafferInfo_Load(object sender, System.EventArgs e)
{
this.sqlDataAdapter1.Fill(tempTable);
this.dataGrid1.DataSource = tempTable.DefaultView;
InputComboBox();//填充【單位編號(hào)】下拉列表框的下拉列表
DataGridStateControl();
DataBindingsFunction();
cmAmend = (CurrencyManager) BindingContext[tempTable];
}
//--------------將數(shù)據(jù)顯示在表格中,并設(shè)置表格參數(shù)------------------
private void DataGridStateControl()
{
DataGridTableStyle ts = new DataGridTableStyle();
DataGridNoActiveCellColumn aColumnTextColumn;
ts.AlternatingBackColor = Color.LightGray;
ts.MappingName = tempTable.TableName;
ts.AllowSorting = false;//不允許進(jìn)行排序
int numCols = tempTable.Columns.Count;
for (int i = 1;i< numCols;i++) //從第二列開始,不顯示第一列的“職員編號(hào)”
{
aColumnTextColumn = new DataGridNoActiveCellColumn();
aColumnTextColumn.MappingName = tempTable.Columns[i].ColumnName;
aColumnTextColumn.HeaderText = tempTable.Columns[i].ColumnName;
aColumnTextColumn.NullText = "";
aColumnTextColumn.Format = "D";
ts.GridColumnStyles.Add(aColumnTextColumn);
}
this.dataGrid1.TableStyles.Add(ts);
this.dataGrid1.Select(0);//選定第一列
}
//--------------為面板中的文本框綁定數(shù)據(jù)集中的相應(yīng)字段------------------
private void DataBindingsFunction()
{
this.txt1.DataBindings.Add("Text",tempTable,"職員編號(hào)");
this.txt2.DataBindings.Add("Text",tempTable,"姓名");
this.txt3.DataBindings.Add("Text",tempTable,"姓名簡碼");
this.txt4.DataBindings.Add("Text",tempTable,"出生日期");
this.txt5.DataBindings.Add("Text",tempTable,"年齡");
this.txt6.DataBindings.Add("Text",tempTable,"文化程度");
this.txt7.DataBindings.Add("Text",tempTable,"畢業(yè)學(xué)校");
this.txt8.DataBindings.Add("Text",tempTable,"健康狀況");
this.txt9.DataBindings.Add("Text",tempTable,"婚姻狀況");
this.txt10.DataBindings.Add("Text",tempTable,"身份證號(hào)碼");
this.txt11.DataBindings.Add("Text",tempTable,"家庭電話");
this.txt12.DataBindings.Add("Text",tempTable,"辦公電話");
this.txt13.DataBindings.Add("Text",tempTable,"手機(jī)");
this.txt14.DataBindings.Add("Text",tempTable,"電子郵件地址");
this.txt15.DataBindings.Add("Text",tempTable,"職工賬號(hào)");
this.txt16.DataBindings.Add("Text",tempTable,"備注");
this.cmb1.DataBindings.Add("Text",tempTable,"性別");
this.cmb2.DataBindings.Add("Text",tempTable,"民族");
this.cmb3.DataBindings.Add("Text",tempTable,"籍貫");
this.cmb4.DataBindings.Add("Text",tempTable,"單位編號(hào)");
}
//-----------為【單位編號(hào)】下拉列表框設(shè)置下拉數(shù)據(jù)辭典---------------
private void InputComboBox()
{
this.strSQL = "select 單位編號(hào) from 組織機(jī)構(gòu)編碼表 order by 單位編號(hào)";
this.da = new SqlDataAdapter(this.strSQL,this.tempConnection);
this.da.Fill(tblDataSource);
for (int i=0;i<tblDataSource.Rows.Count;i++)
this.cmb4.Items.Add(tblDataSource.Rows[i][0]);
}
//-----------處理數(shù)據(jù)導(dǎo)航按鈕與新增修改等事務(wù)---------------
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (e.Button.ToolTipText == "首記錄")
{
this.dataGrid1.UnSelect(cmAmend.Position); //取消選中指定行
cmAmend.Position = 0;
this.dataGrid1.Select(cmAmend.Position); //選中指定行
this.dataGrid1.CurrentRowIndex = cmAmend.Position; //移動(dòng)表頭指示圖標(biāo)
return;
}
if (e.Button.ToolTipText == "上一記錄")
{
if (cmAmend.Position > 0)
{
this.dataGrid1.UnSelect(cmAmend.Position);
cmAmend.Position--;
this.dataGrid1.Select(cmAmend.Position);
this.dataGrid1.CurrentRowIndex = cmAmend.Position;
}
return;
}
if (e.Button.ToolTipText == "下一記錄")
{
if (cmAmend.Position < cmAmend.Count-1)
{
this.dataGrid1.UnSelect(cmAmend.Position);
cmAmend.Position++;
this.dataGrid1.Select(cmAmend.Position);
this.dataGrid1.CurrentRowIndex = cmAmend.Position;
}
return;
}
if (e.Button.ToolTipText == "尾記錄")
{
this.dataGrid1.UnSelect(cmAmend.Position);
cmAmend.Position = cmAmend.Count-1;
this.dataGrid1.Select(cmAmend.Position);
this.dataGrid1.CurrentRowIndex = cmAmend.Position;
return;
}
if (e.Button.ToolTipText == "新增記錄")
{
cmAmend.AddNew();
return;
}
if (e.Button.ToolTipText == "刪除記錄")
{
if (MessageBox.Show(" 確實(shí)要?jiǎng)h除這條記錄嗎?","詢問",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
if (cmAmend.Count > 0)
cmAmend.RemoveAt(cmAmend.Position);
else
{
MessageBox.Show("沒有可以刪除的數(shù)據(jù)","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
catch(Exception express)
{
MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
return;
}
}
if (e.Button.ToolTipText == "提交修改")
{
if (this.txt1.Text.Trim() == "")//檢查不能為空的字段
{
MessageBox.Show("職員編號(hào)不能為空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
if (this.txt2.Text.Trim()=="")
{
MessageBox.Show("職員姓名不能為空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
cmAmend.EndCurrentEdit();//結(jié)束當(dāng)前編輯操作并提交修改
if (tempTable.GetChanges() != null)
{
try
{
this.sqlDataAdapter1.Update(tempTable);
}
catch(Exception express)
{
MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.tempTable.RejectChanges();
}
}
return;
}
if (e.Button.ToolTipText == "取消修改")
{
try
{
cmAmend.CancelCurrentEdit(); //取消編輯
}
catch(Exception express)
{
MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
return;
}
if (e.Button.ToolTipText == "退出")
{
this.Close();
}
}
//---------在【機(jī)構(gòu)編碼】下拉列表框右邊的文本框中顯示與之對(duì)應(yīng)的機(jī)構(gòu)名稱-------
private void cmb4_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataTable tempTable = new DataTable();
string strSearchWord = this.cmb4.Text.Trim();
this.strSQL = "select 單位名稱 from 組織機(jī)構(gòu)編碼表 where 單位編號(hào) = '" + strSearchWord + "'";
this.da = new SqlDataAdapter(this.strSQL,this.tempConnection);
this.da.Fill(tempTable);//查詢獲得機(jī)構(gòu)的單位名稱,并填寫到文本框中
if (tempTable.Rows.Count>0)
{
this.txt17.Text = tempTable.Rows[0][0].ToString().Trim();
this.cmb4.SelectAll();
}
}
//-------------------選擇表格中的任何一個(gè)單元,等同于選中一行----------------
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
if (this.tempTable.Rows.Count > 0)
{
int currentRowNumber = this.dataGrid1.CurrentCell.RowNumber;
if (currentRowNumber >= 0 && currentRowNumber < cmAmend.Count)
cmAmend.Position = currentRowNumber;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -