public Assetmove CreateAssetmove(Assetmove info)
 {
     try
     {
         info.Assetmoveid = new CoderuleManagement().GenerateCodeRule(Assetmove.RuleCode + DateTime.Today.ToString("yyyyMM"), false);
         Management.BeginTransaction();
         Management.CreateAssetmove(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }
        public Assetmove CreateAssetmove(Assetmove info)
        {
            try
            {
                string sqlCommand = @"INSERT INTO ""ASSETMOVE"" (""ASSETMOVEID"",""ASSETCATEGORYID"",""APPLYDATE"",""APPLYUSERID"",""APPLYCONTENT"",""APPROVEUSER"",""APPROVEDATE"",""APPROVERESULT"",""REJECTREASON"",""PLANMOVEDATE"",""ACTUALMOVEDATE"",""CONFIRMDATE"",""CONFIRMUSER"",""MOVEDCONTENT"",""STORAGETITLE"",""STORAGEID"",""SUBCOMPANY"",""SUBCOMPANYCONTACTORID"",""CONTACTPHONE"",""PROJECTCONTACTORID"",""PROJECTCONTACTORPHONE"",""CREATOR"",""CREATEDDATE"") VALUES (:Assetmoveid,:Assetcategoryid,:Applydate,:Applyuserid,:Applycontent,:Approveuser,:Approvedate,:Approveresult,:Rejectreason,:Planmovedate,:Actualmovedate,:Confirmdate,:Confirmuser,:Movedcontent,:Storagetitle,:Storageid,:Subcompany,:Subcompanycontactorid,:Contactphone,:Projectcontactorid,:Projectcontactorphone,:Creator,:Createddate)";
                this.Database.AddInParameter(":Assetmoveid", info.Assetmoveid);//DBType:VARCHAR2
                this.Database.AddInParameter(":Assetcategoryid", info.Assetcategoryid);//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(":Planmovedate", info.Planmovedate);//DBType:DATE
                this.Database.AddInParameter(":Actualmovedate", info.Actualmovedate);//DBType:DATE
                this.Database.AddInParameter(":Confirmdate", info.Confirmdate);//DBType:DATE
                this.Database.AddInParameter(":Confirmuser", info.Confirmuser);//DBType:VARCHAR2
                this.Database.AddInParameter(":Movedcontent", info.Movedcontent);//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.ExecuteNonQuery(sqlCommand);

            }
            finally
            {
                this.Database.ClearParameter();
            }
            return info;
        }
 protected void ReadEntityToControl(Assetmove headInfo)
 {
     litAssetmoveid.Text = headInfo.Assetmoveid;//移机单号
     ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
     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; //项目体(分公司)联系电话
 }
        protected void ReadEntityToControl(Assetmove headInfo)
        {
            litAssetmoveid.Text = headInfo.Assetmoveid;//移机单号
            ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
            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.Planmovedate.HasValue)
            {
                litPlanmovedate.Text = headInfo.Planmovedate.Value.ToString(UiConst.DateFormat);//计划移机日期
            }
            if (headInfo.Approvedate.HasValue)
            {
                litApprovedate.Text = headInfo.Approvedate.Value.ToString(UiConst.DateTimeFormat);//回复时间
            }
            litApproveuser.Text = headInfo.Approveuser;//回复人
            litMovedcontent.Text = headInfo.Movedcontent;//已移机明细
            if (headInfo.Confirmdate.HasValue)
            {
                litConfirmdate.Text = headInfo.Confirmdate.Value.ToString(UiConst.DateFormat);//确认日期
            }
            if (headInfo.Actualmovedate.HasValue)
            {
                litActualmovedate.Text = headInfo.Actualmovedate.Value.ToString(UiConst.DateFormat);//实际移机日期
            }
            litConfirmuser.Text = headInfo.Confirmuser;//确认人
            litApproveresult.Text = EnumUtil.RetrieveEnumDescript(headInfo.Approveresult); //状态
        }
 protected void WriteControlValueToEntity(Assetmove headInfo)
 {
     headInfo.Assetmoveid = Assetmoveid;//移机单号
     headInfo.Assetcategoryid = ucSeletedSystem.Assetcategoryid;//(系统)设备大类
     headInfo.Applycontent = txtApplycontent.Text;//申请内容
     headInfo.Applydate = ucApplyDate.DateValue;//申请日期
     headInfo.Applyuserid = ucApplyuser.UserId;//申请人
     headInfo.Storagetitle = ucSelectProject.Storagetitle;//区分字段:分公司或项目体
     headInfo.Storageid = ucSelectProject.StorageId;//项目体ID或分公司ID
     headInfo.Contactphone = txtContactphone.Text;//联系电话
     headInfo.Projectcontactorid = txtProjectcontactorid.Text;//项目体联系人
     headInfo.Projectcontactorphone = txtProjectcontactorphone.Text;//项目体联系电话
     if (string.IsNullOrEmpty(headInfo.Assetmoveid))
     {
         headInfo.Createddate = DateTime.Now;//创建日期
         headInfo.Creator = WebContext.Current.CurrentUser.Id;//创建人
     }
 }
 protected void SaveData(AssetMoveState maintainState)
 {
     Assetmove headInfo = null;
     if (!string.IsNullOrEmpty(PageUtility.GetQueryStringValue("Assetmoveid"))) //修改
     {
         headInfo = AssetmoveService.RetrieveAssetmoveByAssetmoveid(Assetmoveid);
         if (headInfo == null) { return; }
         WriteControlValueToEntity(headInfo);
         headInfo.Approveresult = maintainState;
         AssetmoveService.UpdateAssetmoveByAssetmoveid(headInfo);
         foreach (var detail in Details)
         {
             detail.Assetmoveid = headInfo.Assetmoveid;
             if (AssetmovedetailService.RetrieveAssetmovedetailByDetailid(detail.Detailid) == null)
             {
                 AssetmovedetailService.CreateAssetmovedetail(detail);
             }
             else
             {
                 AssetmovedetailService.UpdateAssetmovedetailByDetailid(detail);
             }
         }
     }
     else //新增
     {
         headInfo = new Assetmove();
         WriteControlValueToEntity(headInfo);
         headInfo.Approveresult = maintainState;
         AssetmoveService.CreateAssetmove(headInfo);
         foreach (var detail in Details)
         {
             detail.Assetmoveid = headInfo.Assetmoveid;
             AssetmovedetailService.CreateAssetmovedetail(detail);
         }
     }
 }
 protected void ReadEntityToControl(Assetmove headInfo)
 {
     litAssetmoveid.Text = headInfo.Assetmoveid;//移机单号
     ucSeletedSystem.Assetcategoryid = headInfo.Assetcategoryid;//(系统)设备大类
     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; // 项目体(分公司)联系人
     txtProjectcontactorphone.Text = headInfo.Projectcontactorphone; //项目体(分公司)联系电话
 }
 public Assetmove UpdateAssetmoveByAssetmoveid(Assetmove info)
 {
     try
     {
         Management.BeginTransaction();
         Management.UpdateAssetmoveByAssetmoveid(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }