/// <summary> /// Update /// </summary> private void UpdateData() { RC_RoomData data = new RC_RoomData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (RC_RoomData)tran.Result; data.ContractId = lblId.Text.Trim(); //data.CustomerId = lblCustomerId.Text.Trim(); //data.ContractDate = Func.FormatYYYYmmdd(lblContractDate.Text.Trim()); //data.ContractEndDate = Func.FormatYYYYmmdd(lblContractEndDate.Text.Trim()); //data.ReceiveDate = Func.FormatYYYYmmdd(lblReceiveDate.Text.Trim()); //data.Comment = lblComment.Text.Trim(); //data.StaffMount = lblStaffMount.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 = "1"; 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) + ")" : ""; ShowData(); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); mvMessage.AddError(updateUnSuccess); } } }
/// <summary> /// Insert data /// </summary> private void UpdateData() { double BeginContract = Func.ParseDouble(Func.FormatYYYYmmdd(txtContractDate.Text.Substring(0, 10))); double EndContract = Func.ParseDouble(Func.FormatYYYYmmdd(txtContractEndDate.Text.Substring(0, 10))); //string exit = DbHelper.GetScalar("Select Count(*) from RC_Room Where id <> '"+ hidId.Value +"' and delflag = 0 and (BeginContract <= '" + BeginContract + "' and '" + BeginContract + "' <= EndContract) or (BeginContract <= '" + EndContract + "' and '" + EndContract + "' <= EndContract) or ('" + EndContract + "' <= BeginContract and '" + EndContract + "' >= EndContract)"); //if (!exit.Equals("0")) //{ // mvMessage.AddError("Phòng này đang được cho thuê"); // return; //} //Get and Insert Data RC_RoomData data = new RC_RoomData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (RC_RoomData)tran.Result; data.RoomId = drpRoom.SelectedValue; data.VAT = txtVAT.Text.Replace(",", "."); data.MonthManagerPriceVND = txtManagerPriceVND.Text.Trim().Replace(",", "."); data.MonthManagerPriceUSD = txtManagerPriceUSD.Text.Trim().Replace(",", "."); data.MonthRentPriceVND = txtRentPriceVND.Text.Trim().Replace(",", "."); data.MonthRentPriceUSD = txtRentPriceUSD.Text.Trim().Replace(",", "."); 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 = "0"; data.TariffsOfElecId = drpTariffsOfElec.SelectedValue; data.TariffsOfWaterId = drpTariffsOfWater.SelectedValue; data.BeginContract = Func.FormatYYYYmmdd(txtContractDate.Text.Substring(0, 10)); data.EndContract = Func.FormatYYYYmmdd(txtContractEndDate.Text.Substring(0, 10)); data.HourExtraTimePriceUsd = txtHourExtraTimePriceUsd.Text.Replace(",", "."); data.HourExtraTimePriceVND = txtHourExtraTimePriceVND.Text.Replace(",", "."); data.MonthExtraTimePriceUsd = txtMonthExtraTimePriceUSD.Text.Replace(",", "."); data.MonthExtraTimePriceVND = txtMonthExtraTimePriceVND.Text.Replace(",", "."); data.RentType = chkRentType.Checked == true ? "1" : "0"; data.ManagerType = chkManagerType.Checked == true ? "1" : "0"; data.ElecPricePercent = txtElecPricePercent.Text.Replace(",", "."); data.WaterPricePercent = txtWaterPricePercent.Text.Replace(",", "."); data.RentArea = txtRentArea.Text.Replace(",", "."); data.HourExtraTimePriceUsd = txtHourExtraTimePriceUsd.Text.Replace(",", "."); data.HourExtraTimePriceVND = txtHourExtraTimePriceVND.Text.Replace(",", "."); data.MonthExtraTimePriceUsd = txtMonthExtraTimePriceUSD.Text.Replace(",", "."); data.MonthExtraTimePriceVND = txtMonthExtraTimePriceVND.Text.Replace(",", "."); data.FitoutBegin = drpBeginYear.SelectedValue + drpBeginMonth.SelectedValue; data.FitoutEnd = drpEndYear.SelectedValue + drpEndMonth.SelectedValue; data.FitoutManager = chkFitoutManager.Checked == true ? "1" : "0"; data.FitoutParking = chkFitoutParking.Checked == true ? "1" : "0"; data.FitoutService = chkFitoutService.Checked == true ? "1" : "0"; data.FitoutWater = chkFitoutWater.Checked == true ? "1" : "0"; data.FitoutElec = chkFitoutElec.Checked == true ? "1" : "0"; data.FitoutExtraTime = chkFitoutExtraTime.Checked == true ? "1" : "0"; //if (rdoExtraTimeM.Checked == true) //{ // data.ExtratimeType = "0"; // data.HourExtraTimePriceUsd = txtHourExtraTimePriceUsd.Text.Replace(",", "."); // data.HourExtraTimePriceVND = txtHourExtraTimePriceVND.Text.Replace(",", "."); // data.MonthExtraTimePriceUsd = "0"; // data.MonthExtraTimePriceVND = "0"; //} //else //{ // data.ExtratimeType = "1"; // data.HourExtraTimePriceUsd = "0"; // data.HourExtraTimePriceVND = "0"; // data.MonthExtraTimePriceUsd = txtMonthExtraTimePriceUSD.Text.Replace(",", "."); // data.MonthExtraTimePriceVND = txtMonthExtraTimePriceVND.Text.Replace(",", "."); //} tran = factory.GetUpdateObject(data); 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"; hidAction.Value = "Edit"; lblId.Enabled = false; hidId.Value = data.id; } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name); mvMessage.AddError(addUnSuccess); } } }
/// <summary> /// Insert data /// </summary> private void InsertData() { double BeginContract = Func.ParseDouble(Func.FormatYYYYmmdd(txtContractDate.Text.Substring(0, 10))); double EndContract = Func.ParseDouble(Func.FormatYYYYmmdd(txtContractEndDate.Text.Substring(0, 10))); string exit = DbHelper.GetScalar("Select Count(*) from RC_Room Where delflag = 0 and RoomId = '"+ drpRoom.SelectedValue +"' and ((BeginContract <= '" + BeginContract + "' and '" + BeginContract + "' <= EndContract) or (BeginContract <= '" + EndContract + "' and '" + EndContract + "' <= EndContract) or ('" + EndContract + "' <= BeginContract and '" + EndContract + "' >= EndContract))"); if (!exit.Equals("0")) { mvMessage.AddError("Phòng này đang được cho thuê"); return; } if (!checkData()) { return; } double managerVND = Func.ParseDouble(txtManagerPriceVND.Text.Trim()); float managerUSD = Func.ParseFloat(txtManagerPriceUSD.Text.Trim().Replace(",", ".")); if (managerVND != 0 && managerUSD != 0) { mvMessage.AddError("Phí quản lý không được phép nhập cả 2 USD và VND lớn hơn 0. \n Một trong 2 loại phải = 0"); return; } double MonthRentPriceVND = Func.ParseDouble(txtRentPriceVND.Text.Trim()); float MonthRentPriceUSD = Func.ParseFloat(txtRentPriceUSD.Text.Trim().Replace(",", ".")); if (MonthRentPriceVND != 0 && MonthRentPriceUSD != 0) { mvMessage.AddError("Phí Thuê không được phép nhập cả 2 USD và VND lớn hơn 0. \n Một trong 2 loại phải = 0"); return; } if (EndContract < BeginContract) { mvMessage.AddError("Ngày kết thúc hợp đồng phải lớn hơn ngày bắt đầu Hợp đồng"); return; } double HourExtraTimePriceVND = Func.ParseDouble(txtHourExtraTimePriceVND.Text); float HourExtraTimePriceUsd = Func.ParseFloat(txtHourExtraTimePriceUsd.Text.Replace(",", ".")); if (HourExtraTimePriceVND != 0 && HourExtraTimePriceUsd != 0) { mvMessage.AddError("Phí Ngoài Giờ không được phép nhập cả 2 USD và VND lớn hơn 0. \n Một trong 2 loại phải = 0"); return; } double MonthExtraTimePriceVND = Func.ParseDouble(txtMonthExtraTimePriceVND.Text); float MonthExtraTimePriceUsd = Func.ParseFloat(txtMonthExtraTimePriceUSD.Text.Replace(",", ".")); if (MonthExtraTimePriceVND != 0 && MonthExtraTimePriceUsd != 0) { mvMessage.AddError("Phí Ngoài giờ không được phép nhập cả 2 USD và VND lớn hơn 0. \n Một trong 2 loại phải = 0"); return; } //Get and Insert Data RC_RoomData data = new RC_RoomData(); ITransaction tran = factory.GetInsertObject(data); data.ContractId = lblId.Text.Trim(); data.RoomId = drpRoom.SelectedValue; data.VAT = txtVAT.Text.Replace(",", "."); data.MonthManagerPriceVND = txtManagerPriceVND.Text.Trim().Replace(",", "."); data.MonthManagerPriceUSD = txtManagerPriceUSD.Text.Trim().Replace(",", "."); data.MonthRentPriceVND = txtRentPriceVND.Text.Trim().Replace(",", "."); data.MonthRentPriceUSD = txtRentPriceUSD.Text.Trim().Replace(",", "."); data.Comment = lblComment.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 = "0"; data.TariffsOfElecId = drpTariffsOfElec.SelectedValue; data.TariffsOfWaterId = drpTariffsOfWater.SelectedValue; data.BeginContract = Func.FormatYYYYmmdd(txtContractDate.Text.Substring(0, 10)); data.EndContract = Func.FormatYYYYmmdd(txtContractEndDate.Text.Substring(0, 10)); data.RentType = chkRentType.Checked == true ? "1" : "0"; data.ElecPricePercent = txtElecPricePercent.Text.Replace(",", "."); data.WaterPricePercent = txtWaterPricePercent.Text.Replace(",", "."); data.RentArea = txtRentArea.Text.Replace(",", "."); if (rdoExtraTimeM.Checked == true) { data.ExtratimeType = "0"; data.HourExtraTimePriceUsd = txtHourExtraTimePriceUsd.Text.Replace(",", "."); data.HourExtraTimePriceVND = txtHourExtraTimePriceVND.Text.Replace(",", "."); data.MonthExtraTimePriceUsd = "0"; data.MonthExtraTimePriceVND = "0"; } else { data.ExtratimeType = "1"; data.HourExtraTimePriceUsd = "0"; data.HourExtraTimePriceVND = "0"; data.MonthExtraTimePriceUsd = txtMonthExtraTimePriceUSD.Text.Replace(",", "."); data.MonthExtraTimePriceVND = txtMonthExtraTimePriceVND.Text.Replace(",", "."); } data.ExtraTimeMinPriceUSD = txtMinPriceUSD.Text.Replace(",", "."); data.ExtraTimeMinPriceVND = txtMinPriceVND.Text.Replace(",", "."); 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"; hidAction.Value = "Edit"; lblId.Enabled = false; hidId.Value = data.id; //lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; //lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; ShowData(); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name); mvMessage.AddError(addUnSuccess); } }
/// <summary> /// Load data /// </summary> private void LoadData() { for (int i = 2010; i < 2050; i++) { drpBeginYear.Items.Add(new System.Web.UI.WebControls.ListItem(Func.ParseString(i), Func.ParseString(i))); drpEndYear.Items.Add(new System.Web.UI.WebControls.ListItem(Func.ParseString(i), Func.ParseString(i))); } drpBeginYear.Items.FindByValue(DateTime.Now.AddMonths(0).ToString("yyyy")).Selected = true; drpEndYear.Items.FindByValue(DateTime.Now.AddMonths(0).ToString("yyyy")).Selected = true; for (int i = 1; i < 13; i++) { drpBeginMonth.Items.Add(new System.Web.UI.WebControls.ListItem(Func.ParseString(i).PadLeft(2, '0'), Func.ParseString(i).PadLeft(2, '0'))); drpEndMonth.Items.Add(new System.Web.UI.WebControls.ListItem(Func.ParseString(i).PadLeft(2, '0'), Func.ParseString(i).PadLeft(2, '0'))); } drpBeginMonth.Items.FindByValue(DateTime.Now.AddMonths(0).ToString("MM")).Selected = true; drpEndMonth.Items.FindByValue(DateTime.Now.AddMonths(0).ToString("MM")).Selected = true; string sqlElec = " SELECT distinct ID, Name"; sqlElec += " FROM BD_FeeGroup B "; sqlElec += " WHERE B.DelFlag <> '1' and FeeGroup = 1 and B.BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "'"; string sqlWater = " SELECT distinct ID, Name"; sqlWater += " FROM BD_FeeGroup B "; sqlWater += " WHERE B.DelFlag <> '1' and FeeGroup = 2 and B.BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "'"; DbHelper.FillList(drpTariffsOfElec, sqlElec, "Name", "ID"); DbHelper.FillList(drpTariffsOfWater, sqlWater, "Name", "ID"); DbHelper.FillList(drpRoom, "Select ID, '(' + ID + ') ' + Name + '(' + Regional + '-' + [FLOOR] + '-' + convert(nvarchar(10),Area) + 'm2)' as RoomName from BD_Room Where DelFlag <> '1' and BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' Order by Floor", "RoomName", "ID"); string contractID = ""; RC_RoomData dataRoom = new RC_RoomData(); ITransaction tranRoom = factory.GetLoadObject(dataRoom, id); Execute(tranRoom); if (!HasError) { //Get Data dataRoom = (RC_RoomData)tranRoom.Result; drpRoom.SelectedValue = dataRoom.RoomId; txtVAT.Text = dataRoom.VAT; txtManagerPriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthManagerPriceVND)); txtManagerPriceUSD.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthManagerPriceUSD)); txtRentPriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthRentPriceVND)); txtRentPriceUSD.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthRentPriceUSD)); lblComment.Text = dataRoom.Comment; drpTariffsOfElec.SelectedValue = dataRoom.TariffsOfElecId; drpTariffsOfWater.SelectedValue = dataRoom.TariffsOfWaterId; txtContractDate.Text = Func.Formatdmyhms(dataRoom.BeginContract); txtContractEndDate.Text = Func.Formatdmyhms(dataRoom.EndContract); txtHourExtraTimePriceUsd.Text = Func.ParseString(Func.ParseDouble(dataRoom.HourExtraTimePriceUsd)); txtHourExtraTimePriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.HourExtraTimePriceVND)); txtMonthExtraTimePriceUSD.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthExtraTimePriceUsd)); txtMonthExtraTimePriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthExtraTimePriceVND)); chkRentType.Checked = dataRoom.RentType == "1" ? true : false; chkManagerType.Checked = dataRoom.ManagerType == "1" ? true : false; txtElecPricePercent.Text = dataRoom.ElecPricePercent; txtWaterPricePercent.Text = dataRoom.WaterPricePercent; txtRentArea.Text = dataRoom.RentArea; contractID = dataRoom.ContractId; if (!dataRoom.FitoutBegin.Equals("")) { drpBeginYear.SelectedValue = dataRoom.FitoutBegin.Substring(0, 4); drpBeginMonth.SelectedValue = dataRoom.FitoutBegin.Substring(4, 2); } if (!dataRoom.FitoutEnd.Equals("")) { drpEndYear.SelectedValue = dataRoom.FitoutEnd.Substring(0, 4); drpEndMonth.SelectedValue = dataRoom.FitoutEnd.Substring(4, 2); } chkFitoutManager.Checked = (dataRoom.FitoutManager.Equals("1") ? true : false); chkFitoutParking.Checked = (dataRoom.FitoutParking.Equals("1") ? true : false); chkFitoutService.Checked = (dataRoom.FitoutService.Equals("1") ? true : false); chkFitoutWater.Checked = (dataRoom.FitoutWater.Equals("1") ? true : false); chkFitoutElec.Checked = (dataRoom.FitoutElec.Equals("1") ? true : false); chkFitoutExtraTime.Checked = (dataRoom.FitoutExtraTime.Equals("1") ? true : false); RentContractData data = new RentContractData(); ITransaction tran = factory.GetLoadObject(data, contractID); Execute(tran); if (!HasError) { //Get Data data = (RentContractData)tran.Result; lblId.Text = data.ContractId; lblCustomerId.Text = data.CustomerId; lblContractDate.Text = Func.Formatdmyhms(data.ContractDate); lblContractEndDate.Text = Func.Formatdmyhms(data.ContractEndDate); lblReceiveDate.Text = Func.Formatdmyhms(data.ReceiveDate); lblStaffMount.Text = data.StaffMount; lblComment.Text = data.Comment; } } }
/// <summary> /// Load data /// </summary> private void LoadData() { string sqlElec = " SELECT distinct ID, Name"; sqlElec += " FROM BD_FeeGroup B "; sqlElec += " WHERE B.DelFlag <> '1' and FeeGroup = 1 and B.BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "'"; string sqlWater = " SELECT distinct ID, Name"; sqlWater += " FROM BD_FeeGroup B "; sqlWater += " WHERE B.DelFlag <> '1' and FeeGroup = 2 and B.BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "'"; DbHelper.FillList(drpTariffsOfElec, sqlElec, "Name", "ID"); DbHelper.FillList(drpTariffsOfWater, sqlWater, "Name", "ID"); DbHelper.FillList(drpRoom, "Select ID, Name + '(' + Regional + '-' + [FLOOR] + '-' + convert(nvarchar(10),Area) + 'm2)' as RoomName from BD_Room Where DelFlag <> '1' and BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "'", "RoomName", "ID"); string contractID = ""; RC_RoomData dataRoom = new RC_RoomData(); ITransaction tranRoom = factory.GetLoadObject(dataRoom, id); Execute(tranRoom); if (!HasError) { //Get Data dataRoom = (RC_RoomData)tranRoom.Result; drpRoom.SelectedValue = dataRoom.RoomId; txtVAT.Text = dataRoom.VAT; txtManagerPriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthManagerPriceVND)); txtManagerPriceUSD.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthManagerPriceUSD)); txtRentPriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthRentPriceVND)); txtRentPriceUSD.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthRentPriceUSD)); lblComment.Text = dataRoom.Comment; drpTariffsOfElec.SelectedValue = dataRoom.TariffsOfElecId; drpTariffsOfWater.SelectedValue = dataRoom.TariffsOfWaterId; txtContractDate.Text = Func.Formatdmyhms(dataRoom.BeginContract); txtContractEndDate.Text = Func.Formatdmyhms(dataRoom.EndContract); txtHourExtraTimePriceUsd.Text = Func.ParseString(Func.ParseDouble(dataRoom.HourExtraTimePriceUsd)); txtHourExtraTimePriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.HourExtraTimePriceVND)); txtMonthExtraTimePriceUSD.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthExtraTimePriceUsd)); txtMonthExtraTimePriceVND.Text = Func.ParseString(Func.ParseDouble(dataRoom.MonthExtraTimePriceVND)); if (dataRoom.ExtratimeType == "0") { txtMonthExtraTimePriceUSD.Enabled = false; txtMonthExtraTimePriceVND.Enabled = false; txtHourExtraTimePriceUsd.Enabled = true; txtHourExtraTimePriceVND.Enabled = true; } else { txtMonthExtraTimePriceUSD.Enabled = true; txtMonthExtraTimePriceVND.Enabled = true; txtHourExtraTimePriceUsd.Enabled = false; txtHourExtraTimePriceVND.Enabled = false; } chkRentType.Checked = dataRoom.RentType == "1" ? true : false; txtElecPricePercent.Text = dataRoom.ElecPricePercent; txtWaterPricePercent.Text = dataRoom.WaterPricePercent; txtRentArea.Text = dataRoom.RentArea; contractID = dataRoom.ContractId; RentContractData data = new RentContractData(); ITransaction tran = factory.GetLoadObject(data, contractID); Execute(tran); if (!HasError) { //Get Data data = (RentContractData)tran.Result; lblId.Text = data.ContractId; lblCustomerId.Text = data.CustomerId; lblContractDate.Text = Func.Formatdmyhms(data.ContractDate); lblContractEndDate.Text = Func.Formatdmyhms(data.ContractEndDate); lblReceiveDate.Text = Func.Formatdmyhms(data.ReceiveDate); lblStaffMount.Text = data.StaffMount; lblComment.Text = data.Comment; } } }