/// <summary> /// Insert data /// </summary> private void InsertData() { BD_RoomData dataR = new BD_RoomData(); ITransaction tranR = factory.GetLoadObject(dataR, lblRoomId.Text); Execute(tranR); if (!HasError) { //Get Data dataR = (BD_RoomData)tranR.Result; //Get and Insert Data BD_RoomExtraTimeData data = new BD_RoomExtraTimeData(); ITransaction tran = factory.GetInsertObject(data); data.CustomerId = drpCustomerId.SelectedValue; data.WorkingDate = Func.FormatYYYYmmdd(txtWorkingDate.Text.Trim()); //data.EndWD = Func.FormatYYYYmmdd(txtEndWD.Text.Trim()); data.YearMonth = drpYear.SelectedValue + drpMonth.SelectedValue; data.ExtraHour = txtExtraHour.Text.Replace(",", "."); data.Comment = txtComment.Text.Trim(); data.Vat = dataR.Vat.Replace(",", "."); data.PriceUSD = dataR.MonthExtraTimePriceUsd.Replace(",", "."); data.PriceVND = dataR.MonthExtraTimePriceVND.Replace(",", "."); 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 = "0"; data.RoomId = lblRoomId.Text; data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]); 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); ShowData(); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name); mvMessage.AddError(addUnSuccess); } } }
/// <summary> /// Update /// </summary> private void DeleteData(string strId) { BD_RoomExtraTimeData data = new BD_RoomExtraTimeData(); ITransaction tran = factory.GetLoadObject(data, strId); Execute(tran); if (!HasError) { //Get Data data = (BD_RoomExtraTimeData)tran.Result; data.ExtraHour = data.ExtraHour.Replace(",", "."); data.Vat = data.Vat.Replace(",", "."); data.PriceUSD = data.PriceUSD.Replace(",", "."); data.PriceVND = data.PriceVND.Replace(",", "."); data.ModifiedBy = Page.User.Identity.Name; data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); data.DelFlag = "1"; tran = factory.GetUpdateObject(data); Execute(tran); if (!HasError) { OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, deleteSuccess, Page.User.Identity.Name); mvMessage.SetCompleteMessage(deleteSuccess); ScriptManager.RegisterClientScriptBlock(this.btnRegister, this.GetType(), key, postback, true); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); mvMessage.AddError(updateUnSuccess); } } }