Exemplo n.º 1
0
        /// <summary>
        /// Insert data
        /// </summary>
        private void InsertData()
        {
            double PriceVND = Func.ParseDouble(txtPriceVND.Text.Trim());
            float PriceUSD = Func.ParseFloat(txtPriceUSD.Text.Trim().Replace(",", "."));

            if (PriceVND != 0 && PriceUSD != 0)
            {
                mvMessage.AddError("Đơn 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
            BD_TarrifsElecWaterData data = new BD_TarrifsElecWaterData();
            ITransaction tran = factory.GetInsertObject(data);

            data.Name = txtName.Text;
            data.IndexFrom = txtIndexFrom.Text.Replace(",", ".");
            data.PriceVND = txtPriceVND.Text.Replace(",", ".");
            data.PriceUSD = txtPriceUSD.Text.Replace(",", ".");
            data.Comment = txtComment.Text.Trim();
            data.FeeGroup = drpFeeGroup.SelectedValue;

            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.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);
                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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load data
        /// </summary>
        private void LoadData()
        {
            BD_TarrifsElecWaterData data = new BD_TarrifsElecWaterData();
            ITransaction tran = factory.GetLoadObject(data, id);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_TarrifsElecWaterData)tran.Result;
                txtName.Text = data.Name;
                txtIndexFrom.Text = data.IndexFrom;
                txtPriceVND.Text = data.PriceVND;
                txtPriceUSD.Text = data.PriceUSD;
                txtComment.Text = data.Comment;
                chkDelFlag.Checked = "1".Equals(data.DelFlag) ? false : true;

                lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : "";
                lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : "";

                hidId.Value = id;

                drpFeeGroup.SelectedValue = data.FeeGroup;

                //ShowData();
            }
        }
Exemplo n.º 3
0
        private void DeleteData(string strId)
        {
            BD_TarrifsElecWaterData data = new BD_TarrifsElecWaterData();
            ITransaction tran = factory.GetLoadObject(data, strId);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (BD_TarrifsElecWaterData)tran.Result;
                data.DelFlag = "1";
                data.PriceUSD = data.PriceUSD.Replace(",", ".");
                data.PriceVND = data.PriceVND.Replace(",", ".");
                data.IndexFrom = data.IndexFrom.Replace(",", ".");
                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, deleteUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(deleteUnSuccess);
                }
            }
        }