FrmWageSet.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.InitialSet
  11. {
  12. public partial class FrmWageSet : LYFZ.Software.UI.InitialSet.FrmWageSet
  13. {
  14. LYFZ.BLL.BLL_ErpWagesSet wsbll = new BLL.BLL_ErpWagesSet();
  15. public FrmWageSet()
  16. {
  17. this.btnCommissionSet.Click += btnCommissionSet_Click;
  18. this.cmbEmployeeName.ComboBoxTree_NodeMouseClick += cmbEmployeeName_ComboBoxTree_NodeMouseClick;
  19. }
  20. void cmbEmployeeName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  21. {
  22. string dataType = e.Node.Name.ToString().ToLower();
  23. try
  24. {
  25. if (string.IsNullOrEmpty(dataType))
  26. {
  27. WhereStr = "1=1";
  28. }
  29. else
  30. {
  31. if (dataType == "storename")
  32. {
  33. WhereStr = "User_DividedShop='" + e.Node.Tag.ToString() + "'";
  34. }
  35. else if (dataType == "department")
  36. {
  37. if (e.Node.Parent != null)
  38. {
  39. WhereStr = "User_DividedShop='" + e.Node.Parent.Tag.ToString() + "' and User_Department=" + e.Node.Tag.ToString();
  40. }
  41. else
  42. {
  43. WhereStr = " User_Department=" + e.Node.Tag.ToString();
  44. }
  45. }
  46. else
  47. {
  48. WhereStr = "User_EmployeeID='" + e.Node.Tag.ToString() + "'";
  49. }
  50. }
  51. }
  52. catch (Exception ex)
  53. {
  54. MessageBoxCustom.Show(ex.Message);
  55. }
  56. this.PublicFunctionRows();
  57. }
  58. void btnCommissionSet_Click(object sender, EventArgs e)
  59. {
  60. FrmRatingsProportion frmrp = new FrmRatingsProportion();
  61. frmrp.Show();
  62. }
  63. /// <summary>
  64. /// 窗体加载事件
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. protected override void FrmWageSet_Shown(object sender, EventArgs e)
  69. {
  70. // 部门人员绑定
  71. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbEmployeeName, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowResign: false, IsShowAdmin: true);
  72. if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition)
  73. {
  74. this.cmbEmployeeName.TagFindText(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID());
  75. WhereStr = "User_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'";
  76. }
  77. else {
  78. WhereStr = "1=1";
  79. }
  80. this.PublicFunctionRows();
  81. this.btnSaveWages.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.WageCompetence, CustomAttributes.OperatingAuthority.Add);
  82. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.WageCompetence, CustomAttributes.OperatingAuthority.ViewFullBasicSalary))
  83. {
  84. this.btnSaveWages.Enabled = false;
  85. }
  86. if (!LYFZ.BLL.BLL_ErpUser.GetWebInterfaceRights(LYFZ.Model.Model_UserRights.GetSystemMenuPet(), "sm014"))
  87. {
  88. this.btnCommissionSet.Enabled = false;
  89. }
  90. }
  91. string WhereStr = "1=1";
  92. /// <summary>
  93. /// 绑定数据
  94. /// </summary>
  95. public void PublicFunctionRows()
  96. {
  97. DataTable dt = null;
  98. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  99. {
  100. dt = wsbll.GetWagesDataTable(WhereStr + " and (User_Status='在职')");
  101. });
  102. if (dt != null)
  103. {
  104. this.dgv.Rows.Clear();
  105. foreach (DataRow row in dt.Rows)
  106. {
  107. DataGridViewRow dgRow = new DataGridViewRow();
  108. dgRow.CreateCells(this.dgv);
  109. dgRow.Cells[0].Value = 0;
  110. dgRow.Cells[1].Value = row["User_EmployeeID"].ToString();
  111. dgRow.Cells[2].Value = row["User_Name"].ToString();
  112. if (row["Ws_BasicWage"] != null)
  113. {
  114. dgRow.Cells[3].Value = row["Ws_BasicWage"].ToString();
  115. }
  116. else {
  117. dgRow.Cells[3].Value = "";
  118. }
  119. if (row["Ws_Remark"] != null)
  120. {
  121. dgRow.Cells[4].Value = row["Ws_Remark"].ToString();
  122. }
  123. else {
  124. dgRow.Cells[4].Value = "";
  125. }
  126. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.WageCompetence, CustomAttributes.OperatingAuthority.ViewFullBasicSalary))
  127. {
  128. if (row["User_EmployeeID"].ToString() != LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID)
  129. {
  130. if (dgRow.Cells[3].Value.ToString().Length > 0)
  131. {
  132. dgRow.Cells[3].Value = "******";
  133. }
  134. if (dgRow.Cells[4].Value.ToString().Length > 0)
  135. {
  136. dgRow.Cells[4].Value = "******";
  137. }
  138. }
  139. }
  140. this.dgv.Rows.Add(dgRow);
  141. }
  142. this.dgv.ClearSelection();
  143. }
  144. }
  145. /// <summary>
  146. /// dgv事件
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. protected override void dgv_Click(object sender, EventArgs e)
  151. {
  152. this.txtUser_Name.Text = this.dgv.CurrentRow.Cells["User_Name"].Value.ToString();
  153. this.txtUser_Name.Tag = this.dgv.CurrentRow.Cells["User_EmployeeID"].Value.ToString();
  154. this.txtWs_BasicWage.Text = this.dgv.CurrentRow.Cells["Ws_BasicWage"].Value.ToString();
  155. this.txtWs_Remark.Text = this.dgv.CurrentRow.Cells["Ws_Remark"].Value.ToString();
  156. }
  157. /// <summary>
  158. /// 保存工资设置
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. protected override void btnSaveWages_Click(object sender, EventArgs e)
  163. {
  164. try
  165. {
  166. if (string.IsNullOrEmpty(txtUser_Name.Text))
  167. { MessageBoxCustom.Show("姓名不能为空!请选择人员!"); return; }
  168. LYFZ.Model.Model_ErpWagesSet model = null;
  169. DataTable dt = wsbll.GetList("Ws_StaffCode='" + this.txtUser_Name.Tag.ToString() + "'").Tables[0];
  170. if (dt.Rows.Count > 1)
  171. {
  172. for (int i = 1; i < dt.Rows.Count; i++)
  173. {
  174. wsbll.Delete(Convert.ToInt32(dt.Rows[i]["id"].ToString()));
  175. }
  176. }
  177. bool IsSaveed = false;
  178. if (dt.Rows.Count == 0)
  179. {
  180. // 增加
  181. model = new Model.Model_ErpWagesSet();
  182. model.Ws_StaffCode = this.dgv.CurrentRow.Cells["User_EmployeeID"].Value.ToString();
  183. if (!string.IsNullOrEmpty(this.txtWs_BasicWage.Text))
  184. { model.Ws_BasicWage = Convert.ToDecimal(this.txtWs_BasicWage.Text); }
  185. else
  186. { model.Ws_BasicWage = 0.00m; }
  187. model.Ws_EarlyCommissionScheme = "";
  188. model.Ws_Remark = this.txtWs_Remark.Text;
  189. IsSaveed = wsbll.Add(model);
  190. }
  191. else
  192. {
  193. // 修改
  194. model = wsbll.DataRowToModel(dt.Rows[0]);
  195. if (!string.IsNullOrEmpty(this.txtWs_BasicWage.Text))
  196. { model.Ws_BasicWage = Convert.ToDecimal(this.txtWs_BasicWage.Text); }
  197. else
  198. { model.Ws_BasicWage = 0.00m; }
  199. model.Ws_Remark = this.txtWs_Remark.Text;
  200. IsSaveed = wsbll.Update(model);
  201. }
  202. if (IsSaveed)
  203. {
  204. MessageBoxCustom.Show("保存成功!");
  205. this.PublicFunctionRows();
  206. this.txtWs_Remark.Text = "";
  207. this.txtWs_BasicWage.Text = "";
  208. this.txtUser_Name.Text = "";
  209. }
  210. }
  211. catch (Exception ex)
  212. { MessageBoxCustom.Show(ex.Message); }
  213. }
  214. /// <summary>
  215. /// 文本框设置
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. protected override void txtWs_BasicWage_KeyPress(object sender, KeyPressEventArgs e)
  220. {
  221. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  222. { e.Handled = true; }
  223. else if (Char.IsPunctuation(e.KeyChar))
  224. {
  225. if (e.KeyChar == '.')
  226. {
  227. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  228. { e.Handled = true; }
  229. }
  230. else
  231. { e.Handled = true; }
  232. }
  233. }
  234. /// <summary>
  235. /// 关闭
  236. /// </summary>
  237. /// <param name="sender"></param>
  238. /// <param name="e"></param>
  239. protected override void btnClose_Click(object sender, EventArgs e)
  240. {
  241. this.Close();
  242. }
  243. }
  244. }