/*******************************************************************************
* Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PP_0302.cs
* 2.功能描述:日计划新建
* 编辑履历:
* 作者 日期 版本 修改内容
* 徐伟 2019/08/27 1.00 新建
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client.PPModule
{
///
/// 日计划窗体
///
public partial class F_PP_0302 : DKDockPanelBase
{
#region 单例模式 防止窗体被重复创建
private static F_PP_0302 _instance = null;
public static F_PP_0302 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PP_0302();
}
return _instance;
}
}
private void F_PP_0302_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
#region 构造函数
///
/// 日计划窗体
///
public F_PP_0302()
{
InitializeComponent();
//this.Text = "日计划";
}
#endregion
//日计划id,0:插入操作,>0更新操作
public int planId = 0;
///
/// 画面加载
///
///
///
private void F_PP_0302_Load(object sender, System.EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void BtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnSave_Click(object sender, EventArgs e)
{
PlanDayUpdate();
this.Close();
}
//更新操作
private void PlanDayUpdate()
{
//日计划 插入
ClientRequestEntity cre = new ClientRequestEntity();
//用户填写的数据
cre.Properties["YEARNO"] = Convert.ToInt32(planYearNo.Text);
cre.Properties["MONTHNO"] = planMonthNo.Text.Trim().PadLeft(2, '0');
cre.Properties["DAYNO"] = planDayNo.Text.Trim().PadLeft(2, '0');
cre.Properties["PLANNAME"] = planName.Text;
cre.Properties["PLANTYPEID"] = Convert.ToInt32(planType.SelectedValue);
cre.Properties["REMARKS"] = planRemarks.Text;
//自动填写的数据
cre.Properties["STARTDATE"] = Convert.ToDateTime($"{planYearNo.Text}-{planMonthNo.Value.ToString()}-{planDayNo.Value.ToString()}");
cre.Properties["ENDDATE"] = Convert.ToDateTime($"{planYearNo.Text}-{planMonthNo.Value.ToString()}-{planDayNo.Value.ToString()}").AddMonths(1).AddDays(-1);
cre.Properties["UPDATETIME"] = DateTime.Now;
cre.Properties["UPDATEUSERID"] = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
ServiceResultEntity result;
if (planId == 0)
{
//新建专属的列
cre.Properties["PLANVER"] = PPModuleProxy.Service.PlanDayVer(Convert.ToInt32(planType.SelectedValue));
cre.Properties["ACCOUNTID"] = LogInUserInfo.CurrentUser.CurrentUserEntity.AccountID;
cre.Properties["CREATETIME"] = DateTime.Now;
cre.Properties["CREATEUSERID"] = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
result = PPModuleProxy.Service.PlanDayInsert(cre);
}
else
{
//更新时主键要指定值
cre.Properties["PLANID"] = planId;
result = PPModuleProxy.Service.PlanDayUpdate(cre);
}
}
}
}