Example #1
0
        //protected void txtCustomerIdChanged(object sender, EventArgs e)
        //{
        //    string begin = Func.FormatYYYYmmdd(txtDateFrom.Text);
        //    string end = Func.FormatYYYYmmdd(txtDateTo.Text);
        //    if (!String.IsNullOrEmpty(begin) && !String.IsNullOrEmpty(end))
        //    {
        //        //mvMessage.CheckRequired(txt, "* là Danh mục bắt bắt buộc nhập");
        //        txtCustomerId.Text = DbHelper.GetScalar("SELECT A.CustomerId FROM RentContract AS A INNER JOIN RC_Room AS B ON A.ContractId = B.ContractId Where B.BeginContract <= '" + begin + "' and B.BeginContract <= '" + end + "' and B.EndContract >= '" + begin + "' and B.EndContract >= '" + begin + "' and B.RoomId = '" + lblRoomId.Text + "'");
        //        lblCustomerName.Text = "Không tìm thấy có Khách Hàng nào đang sử dụng phòng này";
        //        if (!String.IsNullOrEmpty(txtCustomerId.Text))
        //        {
        //            lblCustomerName.Text = DbHelper.GetScalar("Select Name From Customer Where CustomerId = '" + txtCustomerId.Text + "'");
        //        }
        //    }
        //}
        /// <summary>
        /// Insert data
        /// </summary>
        private void InsertData()
        {
            //Get and Insert Data
            BD_RoomUsedElecWaterData data = new BD_RoomUsedElecWaterData();
            ITransaction tran = factory.GetInsertObject(data);
            data.CustomerId = drpCustomerId.SelectedValue;
            data.DateFrom = Func.FormatYYYYmmdd(txtDateFrom.Text.Trim());
            data.DateTo = Func.FormatYYYYmmdd(txtDateTo.Text.Trim());
            data.OldIndex = txtOldIndex.Text.Trim().Replace(',','.');
            data.NewIndex = txtNewIndex.Text.Trim().Replace(',', '.');
            data.OtherFee01 = txtOtherFee1.Text.Trim().Replace(',', '.');
            data.OtherFee02 = txtOtherFee2.Text.Trim().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.YearMonth = drpYear.SelectedValue + drpMonth.SelectedValue;
            data.DelFlag = "0";

            data.TariffsOfElecId = drpTariffsOfElec.SelectedValue;

            data.RoomId = lblRoomId.Text;
            data.TarrifsType = "1";
            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);

                txtOldIndex.Text = "";
                txtNewIndex.Text = "";

                ShowData();
            }
            else
            {
                OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                mvMessage.AddError(addUnSuccess);
            }
        }
Example #2
0
        /// <summary>
        /// Update
        /// </summary>
        private void DeleteData(string strId)
        {
            BD_RoomUsedElecWaterData data = new BD_RoomUsedElecWaterData();
            ITransaction tran = factory.GetLoadObject(data, strId);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_RoomUsedElecWaterData)tran.Result;
                data.DelFlag = "1";
                data.OldIndex = data.OldIndex.Replace(',','.');
                data.NewIndex = data.NewIndex.Replace(',', '.');
                data.ElecPricePercent = data.ElecPricePercent.Replace(',', '.');
                data.WaterPricePercent = data.WaterPricePercent.Replace(',', '.');
                data.OtherFee01 = data.OtherFee01.Replace(',', '.');
                data.OtherFee02 = data.OtherFee02.Replace(',', '.');

                data.ModifiedBy = Page.User.Identity.Name;
                data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss");
                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);
                }
            }
        }