Exemplo n.º 1
0
        private void cboRollTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            var allCheck = this.panPayRoll_flp.Controls.OfType <CheckBox>();

            foreach (var chk in allCheck)
            {
                chk.Checked = false;
            }
            if (this.cboRollTemplate.Items.Count > 0)
            {
                var result = new PayRollTemplateLogic().GetTemplateByName(this.cboRollTemplate.Text);
                //数据库中有多少个工资项字段
                var pItems = result.GetType().GetProperties().Where(p => p.Name.StartsWith("item"));
                for (int i = 0; i < pItems.Count(); i++)
                {
                    //取出工资项名称
                    var strName = pItems.ElementAt(i).GetValue(result, null);
                    if (strName != null)
                    {
                        //找到工资项名称与chkbox的名子相同的项,选中它.
                        var chkBox = this.panPayRoll_flp.Controls.OfType <CheckBox>().Where(p => p.Text == strName.ToString()).First();
                        if (chkBox != null)
                        {
                            chkBox.Checked = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtTemplateName.Text.Trim()))
            {
                CommUI.MsgOK("模板名称不能为空!");
                this.txtTemplateName.Focus();
                this.DialogResult = DialogResult.None;
                return;
            }
            SalaryItemTemplet entity = new SalaryItemTemplet();
            FrmReadyPayOff    pWin   = this.Owner.ActiveMdiChild as FrmReadyPayOff;
            //被选中的工资项
            var chkBoxs = pWin.panPayRoll_flp.Controls.OfType <CheckBox>().Where(p => p.Checked == true);
            //数据库中有多少个工资项字段
            var pItems = entity.GetType().GetProperties().Where(p => p.Name.StartsWith("item"));

            if (chkBoxs.Count() > pItems.Count())
            {
                CommUI.AlertError("您选的工资项太多,数据库不能存储,请偿试减少工资项!");
                return;
            }
            //设置工资模板的工资项
            for (int i = 0; i < chkBoxs.Count(); i++)
            {
                pItems.ElementAt(i).SetValue(entity, chkBoxs.ElementAt(i).Text, null);
            }

            entity.name      = this.txtTemplateName.Text.Trim();
            entity.inputDate = DateTime.Now;
            entity.inputMan  = this.UserName;
            string strResult = new PayRollTemplateLogic().AddTemplate(entity);

            if (string.IsNullOrEmpty(strResult))
            {
                //CommUI.MsgOK();
            }
            else
            {
                CommUI.AlertError(strResult);
            }
        }
Exemplo n.º 3
0
 private void InitTemplate()
 {
     string[] strResult = new PayRollTemplateLogic().GetAllTemplateName();
     this.cboRollTemplate.DataSource = strResult;
 }