123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- using LYFZ.ComponentLibrary;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.InitialSet
- {
- public partial class FrmWageSet : LYFZ.Software.UI.InitialSet.FrmWageSet
- {
- LYFZ.BLL.BLL_ErpWagesSet wsbll = new BLL.BLL_ErpWagesSet();
- public FrmWageSet()
- {
- this.btnCommissionSet.Click += btnCommissionSet_Click;
- this.cmbEmployeeName.ComboBoxTree_NodeMouseClick += cmbEmployeeName_ComboBoxTree_NodeMouseClick;
- }
- void cmbEmployeeName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- string dataType = e.Node.Name.ToString().ToLower();
- try
- {
- if (string.IsNullOrEmpty(dataType))
- {
- WhereStr = "1=1";
- }
- else
- {
- if (dataType == "storename")
- {
- WhereStr = "User_DividedShop='" + e.Node.Tag.ToString() + "'";
- }
- else if (dataType == "department")
- {
- if (e.Node.Parent != null)
- {
- WhereStr = "User_DividedShop='" + e.Node.Parent.Tag.ToString() + "' and User_Department=" + e.Node.Tag.ToString();
- }
- else
- {
- WhereStr = " User_Department=" + e.Node.Tag.ToString();
- }
- }
- else
- {
- WhereStr = "User_EmployeeID='" + e.Node.Tag.ToString() + "'";
- }
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- this.PublicFunctionRows();
- }
-
- void btnCommissionSet_Click(object sender, EventArgs e)
- {
- FrmRatingsProportion frmrp = new FrmRatingsProportion();
- frmrp.Show();
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmWageSet_Shown(object sender, EventArgs e)
- {
- // 部门人员绑定
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbEmployeeName, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowResign: false, IsShowAdmin: true);
-
- if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition)
- {
- this.cmbEmployeeName.TagFindText(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID());
- WhereStr = "User_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'";
- }
- else {
- WhereStr = "1=1";
- }
- this.PublicFunctionRows();
- this.btnSaveWages.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.WageCompetence, CustomAttributes.OperatingAuthority.Add);
- if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.WageCompetence, CustomAttributes.OperatingAuthority.ViewFullBasicSalary))
- {
- this.btnSaveWages.Enabled = false;
- }
- if (!LYFZ.BLL.BLL_ErpUser.GetWebInterfaceRights(LYFZ.Model.Model_UserRights.GetSystemMenuPet(), "sm014"))
- {
- this.btnCommissionSet.Enabled = false;
- }
- }
- string WhereStr = "1=1";
- /// <summary>
- /// 绑定数据
- /// </summary>
- public void PublicFunctionRows()
- {
- DataTable dt = null;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = wsbll.GetWagesDataTable(WhereStr + " and (User_Status='在职')");
-
- });
- if (dt != null)
- {
- this.dgv.Rows.Clear();
- foreach (DataRow row in dt.Rows)
- {
- DataGridViewRow dgRow = new DataGridViewRow();
- dgRow.CreateCells(this.dgv);
- dgRow.Cells[0].Value = 0;
- dgRow.Cells[1].Value = row["User_EmployeeID"].ToString();
- dgRow.Cells[2].Value = row["User_Name"].ToString();
- if (row["Ws_BasicWage"] != null)
- {
- dgRow.Cells[3].Value = row["Ws_BasicWage"].ToString();
- }
- else {
- dgRow.Cells[3].Value = "";
- }
- if (row["Ws_Remark"] != null)
- {
- dgRow.Cells[4].Value = row["Ws_Remark"].ToString();
- }
- else {
- dgRow.Cells[4].Value = "";
- }
- if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.WageCompetence, CustomAttributes.OperatingAuthority.ViewFullBasicSalary))
- {
- if (row["User_EmployeeID"].ToString() != LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID)
- {
- if (dgRow.Cells[3].Value.ToString().Length > 0)
- {
- dgRow.Cells[3].Value = "******";
- }
- if (dgRow.Cells[4].Value.ToString().Length > 0)
- {
- dgRow.Cells[4].Value = "******";
- }
- }
- }
- this.dgv.Rows.Add(dgRow);
- }
-
- this.dgv.ClearSelection();
- }
-
- }
- /// <summary>
- /// dgv事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgv_Click(object sender, EventArgs e)
- {
- this.txtUser_Name.Text = this.dgv.CurrentRow.Cells["User_Name"].Value.ToString();
- this.txtUser_Name.Tag = this.dgv.CurrentRow.Cells["User_EmployeeID"].Value.ToString();
- this.txtWs_BasicWage.Text = this.dgv.CurrentRow.Cells["Ws_BasicWage"].Value.ToString();
- this.txtWs_Remark.Text = this.dgv.CurrentRow.Cells["Ws_Remark"].Value.ToString();
- }
- /// <summary>
- /// 保存工资设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSaveWages_Click(object sender, EventArgs e)
- {
- try
- {
- if (string.IsNullOrEmpty(txtUser_Name.Text))
- { MessageBoxCustom.Show("姓名不能为空!请选择人员!"); return; }
- LYFZ.Model.Model_ErpWagesSet model = null;
- DataTable dt = wsbll.GetList("Ws_StaffCode='" + this.txtUser_Name.Tag.ToString() + "'").Tables[0];
- if (dt.Rows.Count > 1)
- {
- for (int i = 1; i < dt.Rows.Count; i++)
- {
- wsbll.Delete(Convert.ToInt32(dt.Rows[i]["id"].ToString()));
- }
- }
- bool IsSaveed = false;
- if (dt.Rows.Count == 0)
- {
- // 增加
- model = new Model.Model_ErpWagesSet();
- model.Ws_StaffCode = this.dgv.CurrentRow.Cells["User_EmployeeID"].Value.ToString();
- if (!string.IsNullOrEmpty(this.txtWs_BasicWage.Text))
- { model.Ws_BasicWage = Convert.ToDecimal(this.txtWs_BasicWage.Text); }
- else
- { model.Ws_BasicWage = 0.00m; }
- model.Ws_EarlyCommissionScheme = "";
- model.Ws_Remark = this.txtWs_Remark.Text;
- IsSaveed = wsbll.Add(model);
- }
- else
- {
- // 修改
- model = wsbll.DataRowToModel(dt.Rows[0]);
- if (!string.IsNullOrEmpty(this.txtWs_BasicWage.Text))
- { model.Ws_BasicWage = Convert.ToDecimal(this.txtWs_BasicWage.Text); }
- else
- { model.Ws_BasicWage = 0.00m; }
- model.Ws_Remark = this.txtWs_Remark.Text;
- IsSaveed = wsbll.Update(model);
- }
- if (IsSaveed)
- {
- MessageBoxCustom.Show("保存成功!");
- this.PublicFunctionRows();
- this.txtWs_Remark.Text = "";
- this.txtWs_BasicWage.Text = "";
- this.txtUser_Name.Text = "";
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 文本框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void txtWs_BasicWage_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|