Files
Gatedge.HuiWei.BOS.JJGZMJ/aoyuPlugIn/汇威/hg_xzjxxm.cs
2025-06-20 09:17:36 +08:00

237 lines
9.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Core.WNReport;
using System.Collections.ObjectModel;
using System.ComponentModel;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.Metadata.EntityElement;
namespace aoyuPlugIn
{
[Description("绩效录入")]
public class hg_xzjxxm : AbstractDynamicFormPlugIn
{
public override void EntryBarItemClick(BarItemClickEventArgs e)
{
base.EntryBarItemClick(e);
if (e.BarItemKey == "tbNewxm")
{
Add_XM();
}
else if (e.BarItemKey == "tbyg")
{
addyg();
}
}
//取当前行的值
string get_ygNO(int i)
{
//得到当前行行号
//int i = this.View.Model.GetEntryCurrentRowIndex("k13d7a697920649329a5f90e0365ea5c8");
DynamicObject fgt = this.View.Model.GetValue("FygID",i) as DynamicObject;
string ygno = fgt["Name"].ToString();
return ygno;
}
//调用基础资料表单添加员工
void addyg()
{
string pageId = Guid.NewGuid().ToString();
ListShowParameter showParameter = new ListShowParameter();
//要显示列表的单据标识
showParameter.FormId = "k13d7a697920649329a5f90e0365ea5c8";
showParameter.PageId = pageId;
showParameter.UseOrgId = this.Context.CurrentOrganizationInfo.ID;
showParameter.IsLookUp = true;
//取部门名称
DynamicObject dobjt = this.View.Model.GetValue("FbmID") as DynamicObject;
string bmNm = dobjt["Name"].ToString();
//得到当前行行号
EntryEntity entry = this.View.BusinessInfo.GetEntryEntity("F_QBOY_Entity");
int i = this.Model.GetEntryCurrentRowIndex("F_QBOY_Entity");
int tol = this.Model.GetEntryRowCount("F_QBOY_Entity");
DynamicObject fgt = this.View.Model.GetValue("FygID", i) as DynamicObject;
//取员工编号
//string billNo = Convert.ToString(this.Model.GetValue("FNUMBER"));
string tj = "";
if (fgt is null)
tj ="FbmNm='"+ bmNm+"'";
else
tj = "FNAME='" + fgt["Name"].ToString()+"'";
//this.View.ShowErrMessage("员工姓名" + billNo);
showParameter.ListFilterParameter.Filter =tj;
ListSelectedRowCollection returndata = new ListSelectedRowCollection();
//this.View.ShowForm(showParameter);//直接显示窗体,不用返回值
this.View.ShowForm(showParameter, new Action<FormResult>((result) =>
{
if (result.ReturnData != null)
{
returndata = result.ReturnData as ListSelectedRowCollection;
int j = 0;
foreach (ListSelectedRow dObj in returndata)
{
if (i==tol)
{ this.Model.CreateNewEntryRow("F_QBOY_Entity"); // 新增一行,需要调用的单据体
tol++;
}
//设置员工ID
this.Model.SetValue("FygID", dObj.DataRow["FygID"].ToString(), i);
//设置项目ID
this.Model.SetValue("FJXXMID", dObj.DataRow["FxmID"].ToString(), i);
//设置岗位ID
this.Model.SetValue("FgwID", dObj.DataRow["FgwID"].ToString(), i);
//目标值
this.Model.SetValue("Fmbz", dObj.DataRow["Fmbz"].ToString(), i);
//权重
this.Model.SetValue("Fqz", dObj.DataRow["Fqz"].ToString(), i);
////设置员工ID
//this.Model.SetValue("FJXXMID", ygID, i);
////Double FCPID = Convert.ToDouble(dObj.FICPID_ID);
//string t = dObj.DataRow["FxmID"].ToString();
////this.View.ShowMessage(t);
//// 新增一行,需要调用的单据体
//this.Model.CreateNewEntryRow("F_QBOY_Entity");
//// 设置字段值
//this.Model.SetValue("FJXXMID", t, i);
i++;
j++;
}
this.View.UpdateView("F_QBOY_Entity");
}
}));
}
//调用单据添加项目
public void Add_XM()
{
//当前行ID GetEntryCurrentRowIndex
string ygID = this.View.Model.GetEntryCurrentRowIndex("FygID").ToString();
//当前行行号
EntryEntity entry = this.View.BusinessInfo.GetEntryEntity("FEntityKey");
int entryCurrentRowIndex = this.Model.GetEntryCurrentRowIndex("FEntityKey");
string pageId = Guid.NewGuid().ToString();
ListShowParameter showParameter = new ListShowParameter();
//被调用的单据体标识
showParameter.FormId = "kd0081e4d05cc40c499bf0cf8fb0d4460";
showParameter.PageId = pageId;
showParameter.UseOrgId = this.Context.CurrentOrganizationInfo.ID;
showParameter.IsLookUp = true;
//先取部门ID
DynamicObject fgt = this.View.Model.GetValue("FbmID") as DynamicObject;
string billNo = fgt["Number"].ToString();
//string billNo = Convert.ToString(this.Model.GetValue("FNUMBER"));
showParameter.ListFilterParameter.Filter = "FNUMBER='" + billNo + "'";
ListSelectedRowCollection returndata = new ListSelectedRowCollection();
//this.View.ShowForm(showParameter);//直接显示窗体,不用返回值
this.View.ShowForm(showParameter, new Action<FormResult>((result) =>
{
if (result.ReturnData != null)
{
returndata = result.ReturnData as ListSelectedRowCollection;
int i = 0;
foreach (ListSelectedRow dObj in returndata)
{
//设置员工ID
this.Model.SetValue("FJXXMID", ygID, i);
//Double FCPID = Convert.ToDouble(dObj.FICPID_ID);
string t = dObj.DataRow["FxmID_ID"].ToString();
//this.View.ShowMessage(t);
// 新增一行,需要调用的单据体
this.Model.CreateNewEntryRow("F_QBOY_Entity");
// 设置字段值
this.Model.SetValue("FJXXMID", t, i);
i++;
}
this.View.UpdateView("F_QBOY_Entity");
}
}));
}
//行数据变动
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
int hh = Convert.ToInt16(e.Row);
string t =e.Field.ToString();
if (t == "得分")
{
Double df =Convert.ToDouble( e.NewValue.ToString());
//df = this.View.Model.GetValue("FYGID", hh).ToString();
//this.View.ShowMessage(df.ToString());
jsgrzdf(hh, df);
}
}
//计算个人总得分
void jsgrzdf(int hh, double df)
{
try {
//EntryEntity entry = this.View.BusinessInfo.GetEntryEntity("F_QBOY_Entity");
int zhh = this.Model.GetEntryRowCount("F_QBOY_Entity");
if (hh == 0)//第一行
{
this.View.Model.SetValue("FDF", df, hh);
}
else
{
//--本行的员工ID
Int64 bhygID = Convert.ToInt64((this.View.Model.GetValue("F_YGNO", hh) as DynamicObject)["ID"]);
double zdf = df;
for (int i = hh; i >-1; i--)//从当前行往上循环
{
//--上一行的员工ID
Int64 ygID = Convert.ToInt64((this.View.Model.GetValue("F_YGNO", i-1) as DynamicObject)["ID"]);
if (bhygID != ygID)//本行员工ID不等于上一行员工ID就付值退出
{
this.View.Model.SetValue("FDF", zdf, hh);
break;
}
else
{
zdf =zdf+ Convert.ToDouble(this.View.Model.GetValue("FPF", i - 1).ToString());
}
}
}
}
catch(Exception ex) { this.View.ShowMessage("计算个人总得分时发生错误为:" + ex.Message); }
this.View.UpdateView("F_QBOY_Entity");
}
}
}