/// <summary> /// Load data /// </summary> private void LoadData() { BD_WorkingHourData data = new BD_WorkingHourData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (BD_WorkingHourData)tran.Result; txtId.Text = data.WorkingHourId; txtName.Text = data.Name; txtComment.Text = data.Comment; chkDelFlag.Checked = "1".Equals(data.DelFlag) ? false : true; drpJobType.SelectedValue = data.JobTypeId; lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; } }
/// <summary> /// Update /// </summary> private void UpdateData() { BD_WorkingHourData data = new BD_WorkingHourData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (BD_WorkingHourData)tran.Result; data.WorkingHourId = txtId.Text.Trim(); data.Name = txtName.Text.Trim(); data.Comment = txtComment.Text.Trim(); data.ModifiedBy = Page.User.Identity.Name; data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); data.DelFlag = true.Equals(chkDelFlag.Checked) ? "0" : "1"; data.JobTypeId = drpJobType.SelectedValue; tran = factory.GetUpdateObject(data); Execute(tran); if (!HasError) { OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateSuccess, Page.User.Identity.Name); mvMessage.SetCompleteMessage(updateSuccess); ScriptManager.RegisterClientScriptBlock(this.btnRegister, this.GetType(), key, postback, true); lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); mvMessage.AddError(updateUnSuccess); } } }
/// <summary> /// Insert data /// </summary> private void InsertData() { //Get and Insert Data BD_WorkingHourData data = new BD_WorkingHourData(); ITransaction tran = factory.GetInsertObject(data); data.Name = txtName.Text.Trim(); data.Comment = txtComment.Text.Trim(); data.ModifiedBy = Page.User.Identity.Name; data.CreatedBy = Page.User.Identity.Name; data.Created = DateTime.Now.ToString("yyyyMMddHHmmss"); data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); data.DelFlag = true.Equals(chkDelFlag.Checked) ? "0" : "1"; data.WorkingHourId = txtId.Text.Trim(); data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]); data.JobTypeId = drpJobType.SelectedValue; Execute(tran); if (!HasError) { OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name); mvMessage.SetCompleteMessage(addSuccess); ScriptManager.RegisterClientScriptBlock(this.btnRegister, this.GetType(), key, postback, true); btnRegister.CommandName = "Register"; hidId.Value = data.id; hidAction.Value = "Edit"; txtId.Enabled = false; lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name); mvMessage.AddError(addUnSuccess); } }