private bool CheckForm() { var chkBoxs = panPayRoll_flp.Controls.OfType <CheckBox>().Where(p => p.Checked == true); if (chkBoxs.Count() == 0) { CommUI.AlertError("请您选择至少一个要发放的工资项!"); return(false); } //没有选择增项 var bIsAllMinus = panPayRoll_flp.Controls.OfType <CheckBox>().Where(p => p.Checked == true && (p.Tag as PayRollItem).IsMinus == false).Count() == 0; if (bIsAllMinus) { CommUI.AlertError("您目前选择的工资项无法发放,请再选择能够发放的工资项!"); return(false); } string[] strInsuranceItems = new string[] { "养老保险", "医疗保险", "失业保险", "医疗大额保险", "住房公积金", "扣税" }; //选中保险了,但没有选"基本工资"提示不能发放. bool bChkedInsurance = (from control in panPayRoll_flp.Controls.OfType <CheckBox>() where strInsuranceItems.Contains(control.Text) && control.Checked == true select control).Count() > 0; if (bChkedInsurance == true) { var chkBase = (from control in panPayRoll_flp.Controls.OfType <CheckBox>() where control.Text == "基本工资" select control).FirstOrDefault(); if (chkBase == null) { CommUI.AlertError("没有基本工资项,不能发放工资!"); return(false); } if (chkBase.Checked == false) { if (CommUI.Confirm("发放保险或扣税必须选择基本工资项!") != DialogResult.OK) { return(false); } else { chkBase.Checked = true; } } } return(true); }
private void btnDeletePosition_Click(object sender, EventArgs e) { if (this.dtgPosition.RowCount == 0 || this.dtgPosition.SelectedRows.Count == 0) { return; } if (CommUI.Confirm("确定要删除吗?") == DialogResult.No) { return; } int[] rowsID = (from System.Windows.Forms.DataGridViewRow row in this.dtgPosition.SelectedRows select int.Parse(row.Cells[0].Value.ToString())).ToArray <int>(); if (rowsID.Length == 0) { try { rowsID = new int[1] { int.Parse(this.dtgPosition.CurrentRow.Cells[0].Value.ToString()) }; } catch (System.Exception) { } if (rowsID.Length == 0) { return; } } try { new EmployeeLogic().RemovePosition(rowsID); } catch { CommUI.AlertError("使用中的职位无法删除!"); } this.BindPosition(); }