Ejemplo 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
            CustomerServiceData data = new CustomerServiceData();
            ITransaction tran = factory.GetInsertObject(data);
            data.CustomerId = hidId.Value;
            data.Service = txtService.Text.Trim();
            data.ServiceDateFrom = Func.FormatYYYYmmdd(txtServiceDateFrom.Text.Trim());
            data.ServiceDateTo = Func.FormatYYYYmmdd(txtServiceDateTo.Text.Trim());

            data.PriceUSD = txtPriceUSD.Text.Trim().Replace(",", ".");
            data.PriceVND = txtPriceVND.Text.Trim().Replace(",", ".");
            data.Mount = txtMount.Text.Trim().Replace(",", ".");
            data.VAT = txtVAT.Text.Trim().Replace(",", ".");
            data.OtherFee01 = "0";
            data.OtherFee02 = "0";
            data.YearMonth = drpYear.SelectedValue + drpMonth.SelectedValue;
            data.Unit = txtUnit.Text;

            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";

            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);

                //txtDescription.Text = "";
                //txtComplainDate.Text = "";
                txtComment.Text = "";

                ShowData();
            }
            else
            {
                OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                mvMessage.AddError(addUnSuccess);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update
        /// </summary>
        private void DeleteData(string strId)
        {
            CustomerServiceData data = new CustomerServiceData();
            ITransaction tran = factory.GetLoadObject(data, strId);
            Execute(tran);
            if (!HasError)
            {
                //Get Data
                data = (CustomerServiceData)tran.Result;
                data.PriceUSD = data.PriceUSD.Replace(",", ".");
                data.PriceVND = data.PriceVND.Replace(",", ".");
                data.Mount = data.Mount.Replace(",", ".");
                data.VAT = data.VAT.Replace(",", ".");
                data.OtherFee01 = "0";
                data.OtherFee02 = "0";
                data.Unit = txtUnit.Text;

                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);
                }
            }
        }