public Assetmaintain CreateAssetmaintain(Assetmaintain info)
 {
     try
     {
         info.Assetmaintainid = new CoderuleManagement().GenerateCodeRule(Assetmaintain.RuleCode + DateTime.Today.ToString("yyyyMM"), false);
         Management.BeginTransaction();
         Management.CreateAssetmaintain(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }
        public Assetmaintain CreateAssetmaintain(Assetmaintain info)
        {
            try
            {

                this.Database.AddInParameter(":Assetmaintainid", info.Assetmaintainid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Assetcategoryid", info.Assetcategoryid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Maintaintype", info.Maintaintype);//DBType:VARCHAR2
                this.Database.AddInParameter(":Applydate", info.Applydate);//DBType:DATE
                this.Database.AddInParameter(":Applyuserid", info.Applyuserid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Applycontent", info.Applycontent);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Approveuser", info.Approveuser);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Approvedate", info.Approvedate);//DBType:DATE
                this.Database.AddInParameter(":Approveresult", info.Approveresult);//DBType:NUMBER
                this.Database.AddInParameter(":Rejectreason", info.Rejectreason);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Planmaintaindate", info.Planmaintaindate);//DBType:DATE
                this.Database.AddInParameter(":Actualmaintaindate", info.Actualmaintaindate);//DBType:DATE
                this.Database.AddInParameter(":Confirmdate", info.Confirmdate);//DBType:DATE
                this.Database.AddInParameter(":Confirmuser", info.Confirmuser);//DBType:VARCHAR2
                this.Database.AddInParameter(":Maintaincontent", info.Maintaincontent);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Storagetitle", info.Storagetitle);//DBType:VARCHAR2
                this.Database.AddInParameter(":Storageid", info.Storageid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Subcompany", info.Subcompany);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Subcompanycontactorid", info.Subcompanycontactorid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Contactphone", info.Contactphone);//DBType:VARCHAR2
                this.Database.AddInParameter(":Projectcontactorid", info.Projectcontactorid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Projectcontactorphone", info.Projectcontactorphone);//DBType:VARCHAR2
                this.Database.AddInParameter(":Creator", info.Creator);//DBType:VARCHAR2
                this.Database.AddInParameter(":Createddate", info.Createddate);//DBType:DATE
                this.Database.AddInParameter(":Reason", info.Reason);//DBType:NVARCHAR2
                string sqlCommand = @"INSERT INTO ""ASSETMAINTAIN"" (""ASSETMAINTAINID"",""ASSETCATEGORYID"",""MAINTAINTYPE"",""APPLYDATE"",""APPLYUSERID"",""APPLYCONTENT"",""APPROVEUSER"",""APPROVEDATE"",""APPROVERESULT"",""REJECTREASON"",""PLANMAINTAINDATE"",""ACTUALMAINTAINDATE"",""CONFIRMDATE"",""CONFIRMUSER"",""MAINTAINCONTENT"",""STORAGETITLE"",""STORAGEID"",""SUBCOMPANY"",""SUBCOMPANYCONTACTORID"",""CONTACTPHONE"",""PROJECTCONTACTORID"",""PROJECTCONTACTORPHONE"",""CREATOR"",""CREATEDDATE"",""REASON"") VALUES (:Assetmaintainid,:Assetcategoryid,:Maintaintype,:Applydate,:Applyuserid,:Applycontent,:Approveuser,:Approvedate,:Approveresult,:Rejectreason,:Planmaintaindate,:Actualmaintaindate,:Confirmdate,:Confirmuser,:Maintaincontent,:Storagetitle,:Storageid,:Subcompany,:Subcompanycontactorid,:Contactphone,:Projectcontactorid,:Projectcontactorphone,:Creator,:Createddate,:Reason)";
                this.Database.ExecuteNonQuery(sqlCommand);
            }
            finally
            {
                this.Database.ClearParameter();
            }
            return info;
        }
 protected void ReadEntityToControl(Assetmaintain headInfo)
 {
     litAssetmaintainid.Text = headInfo.Assetmaintainid;//维修单编号
     ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
     ucMaintaintype.Configid = headInfo.Maintaintype; //保修来源:(项目体、自检、月检)数据字典
     if (headInfo.Applydate.HasValue)
     {
         litApplydate.Text = headInfo.Applydate.Value.ToString(UiConst.DateFormat);//申请维修日期
     }
     ucApplyuser.UserId = headInfo.Applyuserid;//申请人
     litApplycontent.Text = headInfo.Applycontent;//申请内容
     ucSelectProject.StorageId = headInfo.Storageid; //区分字段:分公司或项目体
     ucSelectProject.Storagetitle = headInfo.Storagetitle; //项目体ID或分公司ID
     litContactphone.Text = headInfo.Contactphone;//联系电话
     litProjectcontactorid.Text = headInfo.Projectcontactorid; // 项目体(分公司)联系人
     litProjectcontactorphone.Text = headInfo.Projectcontactorphone; //项目体(分公司)联系电话
     if (headInfo.Approvedate.HasValue)
     {
         litApprovedate.Text = headInfo.Approvedate.Value.ToString(UiConst.DateTimeFormat);//回复时间
     }
     litApproveuser.Text = headInfo.Approveuser;//回复人
     if (headInfo.Planmaintaindate.HasValue)
     {
         litPlanmaintaindate.Text = headInfo.Planmaintaindate.Value.ToString(UiConst.DateFormat);//计划维修日期
     }
     if(!string.IsNullOrEmpty(headInfo.Reason))
     {
         int index = -1;
         if (ddlReason.Items.Count > 0)
         {
             for (int i = 0; i < ddlReason.Items.Count; i++)
             {
                 var currentItem = ddlReason.Items[i];
                 if (currentItem.Value.Contains(headInfo.Reason))
                 {
                     ddlReason.SelectedIndex = i;
                     index = i;
                     break;
                 }
             }
         }
         if (index == -1)
         {
             txtReason.Text = headInfo.Reason;
             for (int i = 0; i < ddlReason.Items.Count; i++)
             {
                 var currentItem = ddlReason.Items[i];
                 if (currentItem.Value.Contains("其他"))
                 {
                     ddlReason.SelectedIndex = i;
                     break;
                 }
             }
         }
     }
 }
 protected void WriteControlValueToEntity(Assetmaintain assetmaintain)
 {
     assetmaintain.Assetmaintainid = Assetmaintainid;//维修单编号
     assetmaintain.Assetcategoryid = ucSeletedSystem.Assetcategoryid;//(系统)设备大类
     assetmaintain.Maintaintype = ucMaintaintype.Configid;//保修来源:(项目体、自检、月检)数据字典
     assetmaintain.Applycontent = txtApplycontent.Text;//申请内容
     assetmaintain.Applydate = ucApplyDate.DateValue;//申请日期
     assetmaintain.Applyuserid = ucApplyuser.UserId;//申请人
     assetmaintain.Storagetitle = ucSelectProject.Storagetitle;//区分字段:分公司或项目体
     assetmaintain.Storageid = ucSelectProject.StorageId;//项目体ID或分公司ID
     assetmaintain.Contactphone = txtContactphone.Text;//联系电话
     assetmaintain.Projectcontactorid = txtProjectcontactorid.Text.Trim();//项目体联系人
     assetmaintain.Projectcontactorphone = txtProjectcontactorphone.Text;//项目体联系电话
     if (string.IsNullOrEmpty(assetmaintain.Assetmaintainid))
     {
         assetmaintain.Createddate = DateTime.Now;//创建日期
         assetmaintain.Creator = WebContext.Current.CurrentUser.Id;//创建人
     }
 }
 protected void SaveData(AssetMaintainState maintainState)
 {
     Assetmaintain headInfo = null;
     if (!string.IsNullOrEmpty(PageUtility.GetQueryStringValue("Assetmaintainid"))) //修改
     {
         headInfo = AssetmaintainService.RetrieveAssetmaintainByAssetmaintainid(Assetmaintainid);
         if (headInfo == null) { return; }
         WriteControlValueToEntity(headInfo);
         headInfo.Approveresult = maintainState;
         AssetmaintainService.UpdateAssetmaintainByAssetmaintainid(headInfo);
         foreach (var detail in Details)
         {
             detail.Assetmaintainid = headInfo.Assetmaintainid;
             if (AssetmaintaindetailService.RetrieveAssetmaintaindetailByDetailid(detail.Detailid) == null)
             {
                 AssetmaintaindetailService.CreateAssetmaintaindetail(detail);
             }
             else
             {
                 AssetmaintaindetailService.UpdateAssetmaintaindetailByDetailid(detail);
             }
         }
     }
     else //新增
     {
         headInfo = new Assetmaintain();
         WriteControlValueToEntity(headInfo);
         headInfo.Approveresult = maintainState;
         AssetmaintainService.CreateAssetmaintain(headInfo);
         foreach (var detail in Details)
         {
             detail.Assetmaintainid = headInfo.Assetmaintainid;
             AssetmaintaindetailService.CreateAssetmaintaindetail(detail);
         }
     }
 }
 protected void ReadEntityToControl(Assetmaintain headInfo)
 {
     litAssetmaintainid.Text = headInfo.Assetmaintainid;//维修单编号
     ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
     ucMaintaintype.Configid = headInfo.Maintaintype; //保修来源:(项目体、自检、月检)数据字典
     ucApplyDate.DateValue = headInfo.Applydate;//申请维修日期
     ucApplyuser.UserId = headInfo.Applyuserid;//申请人
     txtApplycontent.Text = headInfo.Applycontent;//申请内容
     ucSelectProject.StorageId = headInfo.Storageid; //区分字段:分公司或项目体
     ucSelectProject.Storagetitle = headInfo.Storagetitle; //项目体ID或分公司ID
     txtContactphone.Text = headInfo.Contactphone;//联系电话
     txtProjectcontactorid.Text = headInfo.Projectcontactorid.Trim(); // 项目体(分公司)联系人
     txtProjectcontactorphone.Text = headInfo.Projectcontactorphone; //项目体(分公司)联系电话
 }
        protected void ReadEntityToControl(Assetmaintain headInfo)
        {
            litAssetmaintainid.Text = headInfo.Assetmaintainid;//维修单编号
            ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
            ucMaintaintype.Configid = headInfo.Maintaintype; //保修来源:(项目体、自检、月检)数据字典
            if (headInfo.Applydate.HasValue)
            {
                litApplydate.Text = headInfo.Applydate.Value.ToString(UiConst.DateFormat);//申请维修日期
            }
            ucApplyuser.UserId = headInfo.Applyuserid;//申请人
            litApplycontent.Text = headInfo.Applycontent;//申请内容
            ucSelectProject.StorageId = headInfo.Storageid; //区分字段:分公司或项目体
            ucSelectProject.Storagetitle = headInfo.Storagetitle; //项目体ID或分公司ID
            litContactphone.Text = headInfo.Contactphone;//联系电话
            litProjectcontactorid.Text = headInfo.Projectcontactorid; // 项目体(分公司)联系人
            litProjectcontactorphone.Text = headInfo.Projectcontactorphone; //项目体(分公司)联系电话

            if (headInfo.Planmaintaindate.HasValue)
            {
                litPlanmaintaindate.Text = headInfo.Planmaintaindate.Value.ToString(UiConst.DateFormat);//计划维修日期
            }
            if (headInfo.Approvedate.HasValue)
            {
                litApprovedate.Text = headInfo.Approvedate.Value.ToString(UiConst.DateTimeFormat);//回复时间
            }
            litApproveuser.Text = headInfo.Approveuser;//回复人
            litMaintaincontent.Text = headInfo.Maintaincontent;//已维修明细
            if (headInfo.Confirmdate.HasValue)
            {
                litConfirmdate.Text = headInfo.Confirmdate.Value.ToString(UiConst.DateFormat);//确认日期
            }
            if (headInfo.Actualmaintaindate.HasValue)
            {
                litActualmaintaindate.Text = headInfo.Actualmaintaindate.Value.ToString(UiConst.DateFormat);//实际维修日期
            }
            litConfirmuser.Text = headInfo.Confirmuser;//确认人
            litApproveresult.Text = EnumUtil.RetrieveEnumDescript(headInfo.Approveresult); //状态
            litReason.Text = headInfo.Reason;//修复原因
        }
 protected void ReadEntityToControl(Assetmaintain headInfo)
 {
     litAssetmaintainid.Text = headInfo.Assetmaintainid;//维修单编号
     ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
     ucMaintaintype.Configid = headInfo.Maintaintype; //保修来源:(项目体、自检、月检)数据字典
     if(headInfo.Applydate.HasValue)
     {
         litApplydate.Text = headInfo.Applydate.Value.ToString(UiConst.DateFormat);//申请维修日期
     }
     ucApplyuser.UserId = headInfo.Applyuserid;//申请人
     litApplycontent.Text = headInfo.Applycontent;//申请内容
     ucSelectProject.StorageId = headInfo.Storageid; //区分字段:分公司或项目体
     ucSelectProject.Storagetitle = headInfo.Storagetitle; //项目体ID或分公司ID
     litContactphone.Text = headInfo.Contactphone;//联系电话
     litProjectcontactorid.Text = headInfo.Projectcontactorid; // 项目体(分公司)联系人
     litProjectcontactorphone.Text = headInfo.Projectcontactorphone; //项目体(分公司)联系电话
 }
 public Assetmaintain UpdateAssetmaintainByAssetmaintainid(Assetmaintain info)
 {
     try
     {
         Management.BeginTransaction();
         Management.UpdateAssetmaintainByAssetmaintainid(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }