118 lines
4.2 KiB
C#
118 lines
4.2 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
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 workRL: AbstractBillPlugIn
|
|
{
|
|
int sbts = 0;
|
|
//单据头菜单点击
|
|
public override void BarItemClick(BarItemClickEventArgs e)
|
|
{
|
|
base.BarItemClick(e);
|
|
try
|
|
{
|
|
if (e.BarItemKey == "tbPL")
|
|
{
|
|
sbts = 0;
|
|
string t = this.View.Model.GetValue("F_YEAR").ToString();
|
|
if (t == "") t = DateTime.Today.Year.ToString();
|
|
string months = this.View.Model.GetValue("F_MONTH").ToString();
|
|
del_data(t, months);
|
|
this.View.Model.SetValue("F_SBTS", sbts);
|
|
|
|
}
|
|
}
|
|
catch(Exception ex) {
|
|
this.View.ShowMessage("取单据体字段数据时发生错误为:"+ex.Message);
|
|
}
|
|
//加日期
|
|
void add_date(string y,string m,string body_nm)
|
|
{
|
|
try {
|
|
var weekdays = new string[] { "0", "1", "2", "3", "4", "5", "6" };
|
|
|
|
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(Convert.ToInt16(y),Convert.ToInt16(m));
|
|
|
|
this.View.Model.BatchCreateNewEntryRow(body_nm, days);
|
|
int sbts = 0;
|
|
for (int i = 1; i <= days; i++)
|
|
{
|
|
string tm = y + "-" + m + "-" + i.ToString();
|
|
this.Model.SetValue("Fdate", tm, i-1);
|
|
string zt = getxt(tm);
|
|
this.Model.SetValue("F_RLZT", zt, i-1);
|
|
if (zt == "上班")
|
|
{
|
|
sbts++;
|
|
this.Model.SetValue("F_GZXS", 1, i - 1);
|
|
}
|
|
else
|
|
{
|
|
this.Model.SetValue("F_GZXS", 2, i - 1);
|
|
}
|
|
|
|
DateTime rq = Convert.ToDateTime(tm);
|
|
string wk=weekdays[(int)rq.DayOfWeek];
|
|
this.Model.SetValue("F_WK", wk, i - 1);
|
|
}
|
|
this.View.Model.SetValue("F_SBTS", sbts, 0);
|
|
|
|
|
|
|
|
}
|
|
catch(Exception ex) {
|
|
this.View.ShowMessage("加日期时发生错误为:" + ex.Message);
|
|
}
|
|
}
|
|
string getxt(string tm)
|
|
{
|
|
DateTime t = Convert.ToDateTime(tm);
|
|
string xx = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(t.DayOfWeek);
|
|
if (xx == "星期六" || xx == "星期日")
|
|
//if (xx == "星期日")
|
|
xx = "休息";
|
|
else
|
|
{
|
|
xx = "上班";
|
|
sbts++;
|
|
}
|
|
return xx;
|
|
}
|
|
void del_data(string y, string m)
|
|
{
|
|
try
|
|
{
|
|
string nm = "F_GAT_GZRLs";
|
|
//取表体最大行数
|
|
int tol = this.Model.GetEntryRowCount(nm);
|
|
tol--;
|
|
for (int i = tol; i > -1; i--)
|
|
{
|
|
this.View.Model.DeleteEntryRow(nm, i); //先删除空行
|
|
}
|
|
add_date(y, m, nm);
|
|
}
|
|
catch (Exception ex)
|
|
{ this.View.ShowMessage("删除表体数据时发生错误为:" + ex.Message); }
|
|
}
|
|
}
|
|
}
|
|
}
|