using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using Kingdee.BOS; using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.Bill.PlugIn.Args; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Core.SqlBuilder; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; namespace aoyuPlugIn { [Description("注塑月工资")] public class zs_ygz : AbstractBillPlugIn { public override void BarItemClick(BarItemClickEventArgs e) { base.BarItemClick(e); //this.View.ShowMessage("Hello World:" + e.BarItemKey.ToString()); if (e.BarItemKey == "tbSCYGZ") { string years = this.View.Model.GetValue("F_YEAR").ToString(); if (years == "" || years == "0") years = DateTime.Today.Year.ToString(); string months = this.View.Model.GetValue("F_MONTH").ToString(); del_data("F_QBOY_Entity", years, months); } //删除窗体数据 void del_data(string bodynm, string y, string m) { try { //取表体最大行数 int tol = this.Model.GetEntryRowCount(bodynm); tol--; for (int i = tol; i > -1; i--) { this.View.Model.DeleteEntryRow(bodynm, i); //先删除空行 } add_data_stort(y, m, bodynm); } catch (Exception ex) { this.View.ShowMessage("删除表体数据时发生错误为:" + ex.Message); } } //加载数据 void add_data_stort(string y, string m, string bodynm) { try { string cs = y + "," + m; var sSql = String.Format("EXEC hw_get_ygz_zs " + cs); var dr = DBServiceHelper.ExecuteDynamicObject(this.Context, sSql); int i = 0; if (dr.Count > 0) { string t = dr[0][0].ToString(); if (t == "1") { this.View.ShowMessage("计算月工资失败:因为日工资有未审核单据"); return; } this.View.Model.BatchCreateNewEntryRow(bodynm, dr.Count); } foreach (var item in dr) { this.Model.SetValue("FYGID", item[0], i); this.Model.SetValue("FJJGZ", item[1], i); this.Model.SetValue("FJSGZ", item[2], i); this.Model.SetValue("FTJBT", item[3], i); this.Model.SetValue("FBMJT", item[4], i); this.Model.SetValue("FYBBT", item[5], i); this.Model.SetValue("FCFBT", item[6], i); this.Model.SetValue("FGLBT", item[7], i); this.Model.SetValue("FOTHER", item[8], i); this.Model.SetValue("FDTGZ", item[9], i); i++; } } catch (Exception ex) { this.View.ShowMessage("加表体数据时发生错误为:" + ex.Message); } } } } }