Exemple #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.txtPayName.Text.Trim() == "")
            {
                MessageBox.Show("工资项名不能为空!", "提示");
                return;
            }
            PayrollAdd oEntity = new PayrollAdd();

            oEntity.name      = this.txtPayName.Text;
            oEntity.inputDate = DateTime.Now;
            oEntity.inputMan  = this.UserName;
            oEntity.remark    = this.txtMemo.Text;
            oEntity.kind      = this.cboHumanType.SelectedIndex;
            if (this.cboAddType.SelectedIndex == 0)
            {
                oEntity.minusPlace = this.cboSub.SelectedIndex == 0 ? false:true;
            }
            oEntity.mark = this.cboAddType.SelectedIndex == 0 ? false:true;
            string strResult = new PayrollLogic().AddPayroll(oEntity);

            if (strResult != "")
            {
                System.Windows.Forms.MessageBox.Show(strResult);
                return;
            }
            this.txtPayName.Text = "";
            this.txtMemo.Text    = "";
            this.BindDataGrid();
        }
Exemple #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dtgList.RowCount == 0 ||
                this.dtgList.SelectedRows.Count == 0)
            {
                return;
            }
            if (MessageBox.Show("确定要删除吗?", "请确认", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            long[] rowsID = (from System.Windows.Forms.DataGridViewRow row in this.dtgList.SelectedRows
                             select long.Parse(row.Cells[0].Value.ToString())).ToArray <long>();

            if (rowsID.Length == 0)
            {
                try
                {
                    rowsID = new long[1] {
                        long.Parse(this.dtgList.CurrentRow.Cells[0].Value.ToString())
                    };
                }catch (System.Exception) {                }
                if (rowsID.Length == 0)
                {
                    return;
                }
            }

            string strResult = new PayrollLogic().RemovePayroll(rowsID);

            if (strResult != "")
            {
                System.Windows.Forms.MessageBox.Show(strResult, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            this.BindDataGrid();
        }