private void BT_GetSalary_Click(object sender, EventArgs e) { try { String UserName = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); String RoleName = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); String RealName = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); int Year = Convert.ToInt32(CB_Year.SelectedItem.ToString()); int Month = Convert.ToInt32(CB_Month.SelectedItem.ToString()); decimal Price = Convert.ToDecimal(dataGridView1.SelectedRows[0].Cells[6].Value.ToString()); DialogResult RS = MessageBox.Show(String.Format("您确认现在为{0}发放{1}年{2}月的工资吗?", RealName, Year, Month), "警告!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (RS == DialogResult.Yes) { if ((bool)List_SalaryInfo.Where( P => P.RoleName == RoleName && P.UserName == UserName && Convert.ToInt32(P.Time.Substring(0, 4)) == Year && Convert.ToInt32(P.Time.Substring(5, 2)) == Month ).FirstOrDefault().SalaryLog_Mark) { MessageBox.Show("您已经领取本月工资!请勿重复申请!"); return; } if (SalaryInfoSummery_Client.GetSalary(((int) List_SalaryInfo.Where( P => P.RoleName == RoleName && P.UserName == UserName && Convert.ToInt32(P.Time.Substring(0, 4)) == Year && Convert.ToInt32(P.Time.Substring(5, 2)) == Month ).FirstOrDefault().SalaryLog_ID), GlobalParams.UserID, RealName, -Price)) { MessageBox.Show("领取工资成功!"); List_SalaryInfo = SalaryInfoSummery_Client.SelectSalaryInfo(ShopID, null, null, null, null, null).ToList(); CB_Month_SelectedIndexChanged(null, null); } else { MessageBox.Show("领取工资失败!"); } } } catch (Exception EX) { MessageBox.Show(EX.Message + " 提示:请只选定您要进行操作的单列!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Form_Salary() { InitializeComponent(); if (ShopID < 0) { MessageBox.Show("您不属于任何店铺,请联系系统管理员分配您的店铺所属!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.Close(); } year = 2012; month = 1; SalaryInfoSummery_Client = (SalaryInfoSummeryClient)ClientFactory.GetClient(ClientType.Type.SalaryInfoSummery); SalaryLog_Client = (SalaryLogClient)ClientFactory.GetClient(ClientType.Type.SalaryLog); List_SalaryInfo = SalaryInfoSummery_Client.SelectSalaryInfo(ShopID, null, null, null, null, null).ToList(); dataGridView1.DataSource = List_SalaryInfo; Bind_Year(); }