175 lines
6.2 KiB
C#
175 lines
6.2 KiB
C#
using SuperMap.RealEstate.CoreFrameWork;
|
||
using SuperMap.RealEstate.NetworkDeployed;
|
||
using SuperMap.RealEstate.Web.UI;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using Business = SuperMap.RealEstate.Personnel.Storage.Business;
|
||
|
||
namespace SuperMap.RealEstate.Personnel.Modules.Personnelfiles
|
||
{
|
||
public partial class PERSONNELFILES : UserControl<Business.PERSONNELFILES>
|
||
{
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (IsPostBack) return;
|
||
if (!string.IsNullOrEmpty(Request["STAFF_ID"]))
|
||
{
|
||
//姓名
|
||
Business.STAFF _STAFF = new Business.STAFF(Transaction);
|
||
_STAFF.STAFF_ID = int.Parse(Request["STAFF_ID"].ToDecrypt());
|
||
if (_STAFF.Select())
|
||
{
|
||
STAFF_ID.Text = _STAFF.STAFF_ID.ToString();
|
||
STAFF_NAME.Text = _STAFF.STAFF_NAME;
|
||
|
||
if (CurrObject == null || CurrObject.PERSONNELFILES_ID == null)
|
||
{
|
||
//没有添加过
|
||
PERSONNELFILES_CODE.Text = GetCode(DateTime.Now.ToString("yyyy"));
|
||
}
|
||
}
|
||
}
|
||
|
||
if (CurrObject.PERSONNELFILES_ID != null)
|
||
{
|
||
PERSONNELFILES_CODE.ReadOnly = true;
|
||
}
|
||
}
|
||
|
||
//载入数据
|
||
public override bool LoadData()
|
||
{
|
||
if (!String.IsNullOrEmpty(Request["ID"]))
|
||
{
|
||
CurrObject.PERSONNELFILES_ID_Encrypt = Request["ID"];
|
||
|
||
bool Flag = this.Select();
|
||
return Flag;
|
||
}
|
||
//默认返回值,工作流组件返回True,功能模块返回False。
|
||
return (WorkFlowPage != null);
|
||
}
|
||
|
||
//在此加入界面的数据初始化(Page_Load之前),如DropDownList的数据源绑定等
|
||
public override void InitializeWebControl()
|
||
{
|
||
//档案类型
|
||
PERSONNELFILES_TYPE.Clear();
|
||
DictionaryHelper.BindingDropDownList("PERSONNELFILES_TYPE", PERSONNELFILES_TYPE.Items, this.Transaction);
|
||
|
||
//传递形式
|
||
OUTTYPE.Clear();
|
||
DictionaryHelper.BindingDropDownList("TRANSFER_MODE", OUTTYPE.Items, this.Transaction);
|
||
}
|
||
|
||
//OnDataAction_XXXXX 有一个系列可用,在此加入界面的逻辑处理
|
||
//e.CancelDataAction 来处理是否取消该动作;
|
||
//失败的原因可以用Page.Alert()传递到页面
|
||
public override void OnDataAction_BeforeSave(DataActionEventArgs<Business.PERSONNELFILES> e)
|
||
{
|
||
if (!string.IsNullOrEmpty(Request["STAFF_ID"]))
|
||
{
|
||
e.CurrObject.STAFF_ID = int.Parse(Request["STAFF_ID"].ToDecrypt());
|
||
}
|
||
else
|
||
{
|
||
throw new Exception("您未选中任何人员");
|
||
}
|
||
e.CurrObject.OPERATE_DATE = DateTime.Now;
|
||
e.CurrObject.OPERATE_USER = Page.PassportInfo.Name;
|
||
e.CurrObject.OPERATE_USERID = Page.PassportInfo.ID;
|
||
|
||
//添加时判断
|
||
if (e.CurrObject == null || e.CurrObject.PERSONNELFILES_ID == null)
|
||
{
|
||
DataTable _POSITIONDataTable = new Business.POSITION(Transaction).ExecuteDataTable(string.Format(
|
||
@"SELECT PERSONNELFILES_CODE FROM PERSONNEL_STORAGE.T_PERSONNELFILES
|
||
WHERE PERSONNELFILES_CODE = '{0}'", e.CurrObject.PERSONNELFILES_CODE));
|
||
if (_POSITIONDataTable.Rows.Count > 0)
|
||
{
|
||
throw new Exception("该档案编号已存在!");
|
||
}
|
||
}
|
||
base.OnDataAction_BeforeSave(e);
|
||
}
|
||
|
||
#region 方法 -> 生成合同编号后四位
|
||
#region 方法 -> 合同编码
|
||
/// <summary>
|
||
/// 规则:0001-9999
|
||
/// 思路:按年份建立序列分配编号后四位
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetCode(string Year)
|
||
{
|
||
string Num = string.Empty;
|
||
DataTable _DataTable = null;
|
||
//查看对应的数据--获得对应的序列数据
|
||
string StrSql = "select PERSONNEL_STORAGE.SEQ_PERSONNELFILES_" + Year + ".NEXTVAL from dual";
|
||
try
|
||
{
|
||
_DataTable = new Business.PERSONNELFILES(Transaction).ExecuteDataTable(StrSql);
|
||
}
|
||
catch
|
||
{
|
||
try
|
||
{
|
||
RetSeqByName(" PERSONNEL_STORAGE.SEQ_PERSONNELFILES_" + Year);
|
||
StrSql = "select PERSONNEL_STORAGE.SEQ_PERSONNELFILES_" + Year + ".NEXTVAL from dual";
|
||
_DataTable = new Business.PERSONNELFILES(Transaction).ExecuteDataTable(StrSql);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
|
||
if (_DataTable != null)
|
||
{
|
||
Num = _DataTable.Rows[0][0].ToString();
|
||
}
|
||
else
|
||
{
|
||
return "00000001";
|
||
}
|
||
if (Num.Length < 8)
|
||
Num = Num.PadLeft(8, '0');
|
||
return Num;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 创建序列
|
||
public bool RetSeqByName(string Seq_Name)
|
||
{
|
||
string StrSql = string.Empty;
|
||
try
|
||
{
|
||
try
|
||
{
|
||
//创建对应的序列
|
||
StrSql = "DROP SEQUENCE " + Seq_Name + "";
|
||
new Business.PERSONNELFILES(Transaction).ExecuteNonQuery(StrSql, null);
|
||
}
|
||
catch
|
||
{ }
|
||
//
|
||
StrSql = "CREATE SEQUENCE " + Seq_Name + " INCREMENT BY 1 START WITH 1 MAXVALUE 9999999999 NOMINVALUE NOCYCLE CACHE 2 NOORDER";
|
||
new Business.PERSONNELFILES(Transaction).ExecuteNonQuery(StrSql, null);
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw ex;
|
||
}
|
||
}
|
||
#endregion
|
||
#endregion
|
||
|
||
|
||
}
|
||
} |