/*******************************************************************************
* Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PP_0102.cs
* 2.功能描述:年计划新建
* 编辑履历:
* 作者 日期 版本 修改内容
* 徐伟 2019/08/27 1.00 新建
*******************************************************************************/
using System;
using System.Reflection;
using System.Windows.Forms;
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_0102 : DKDockPanelBase
{
#region 单例模式 防止窗体被重复创建
private static F_PP_0102 _instance = null;
public static F_PP_0102 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PP_0102();
}
return _instance;
}
}
private void F_PP_0102_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
#region 构造函数
///
/// 年计划窗体
///
public F_PP_0102()
{
InitializeComponent();
//this.Text = "年计划";
}
#endregion
//年计划id,0:插入操作,>0更新操作
public int planId = 0;
///
/// 画面加载
///
///
///
private void F_PP_0102_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)
{
PlanYearUpdate();
this.Close();
}
//更新操作
private void PlanYearUpdate()
{
//年计划 插入
ClientRequestEntity cre = new ClientRequestEntity();
//用户填写的数据
cre.Properties["YEARNO"] = Convert.ToInt32(planYearNo.Text);
cre.Properties["PLANNAME"] = planName.Text;
cre.Properties["PLANTYPEID"] = Convert.ToInt32(planType.SelectedValue);
cre.Properties["REMARKS"] = planRemarks.Text;
cre.Properties["STARTMONTH"] = planStartMonth.Value.ToString();
cre.Properties["ENDMONTH"] = planEndMonth.Value.ToString();
//自动填写的数据
cre.Properties["STARTDATE"] = Convert.ToDateTime($"{planYearNo.Text}-{planStartMonth.Value.ToString()}-01");
cre.Properties["ENDDATE"] = Convert.ToDateTime($"{planYearNo.Text}-{planEndMonth.Value.ToString()}-1").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.PlanYearVer(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.PlanYearInsert(cre);
}
else
{
//更新时主键要指定值
cre.Properties["PLANID"] = planId;
result = PPModuleProxy.Service.PlanYearUpdate(cre);
}
}
}
}