public void UpdatePriceHistory(Int64 ItemID)
        {
            DataTable Dt_Item = Do_Methods_Query.GetQuery("Item", "", "ItemID = " + ItemID);
            DataRow   Dr_Item = null;

            if (Dt_Item.Rows.Count > 0)
            {
                Dr_Item = Dt_Item.Rows[0];
            }
            else
            {
                return;
            }

            DateTime  ServerDate      = Layer02_Common.GetServerDate();
            DataTable Dt_PriceHistory = Do_Methods_Query.GetQuery("Item_PriceHistory", "", "1 = 0");
            DataRow   Dr_PriceHistory = Dt_PriceHistory.NewRow();

            Dr_PriceHistory["ItemID"] = ItemID;
            Dr_PriceHistory["Price"]  = Dr_Item["Price"];
            Dr_PriceHistory["EmployeeID_PostedBy"] = this.mCurrentUser.pDrUser["EmployeeID"];
            Dr_PriceHistory["DatePosted"]          = ServerDate;

            Interface_DataAccess Da = Do_Methods.CreateDataAccess();

            try
            {
                Da.Connect();
                Da.SaveDataRow(Dr_PriceHistory, "Item_PriceHistory");
            }
            catch { }
            finally
            { Da.Close(); }
        }
        bool Save_Validation(ref StringBuilder Sb_Msg)
        {
            WebControl Wc;
            bool       IsValid = true;

            this.Txt_ItemCode.CssClass = Layer01_Constants_Web.CnsCssTextbox;
            if (this.Txt_ItemCode.Text.Trim() == "")
            {
                this.Txt_ItemCode.Text = Layer02_Common.GetSeriesNo("Item");
            }

            Wc = this.Txt_ItemCode;
            ClsBasePageDetails.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , Layer01_Constants_Web.CnsCssTextbox
                , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                , (Layer02_Common.CheckSeriesDuplicate("uvw_Item", "Code", this.mObj.GetKeys(), this.Txt_ItemCode.Text))
                , "Duplicate Item No. found. Please change the Item No." + "<br />");

            Wc = this.Txt_ItemName;
            ClsBasePageDetails.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , Layer01_Constants_Web.CnsCssTextbox
                , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                , (this.Txt_ItemName.Text.Trim() != "")
                , "Item Name is required." + "<br />");

            return(IsValid);
        }
示例#3
0
        public override bool Validate()
        {
            base.mList_ValidationError.Clear();
            ClsItem Obj = (ClsItem)base.mBase;

            if (Do_Methods.Convert_String(Obj.pDr_RowProperty["Code"]) == "")
            {
                Obj.pDr_RowProperty["Code"] = Layer02_Common.GetSeriesNo("Item");
            }

            if (
                Layer02_Common.CheckSeriesDuplicate(
                    "uvw_Item"
                    , "Code"
                    , Obj.GetKeys()
                    , Do_Methods.Convert_String(Obj.pDr_RowProperty["Code"]))
                )
            {
                base.AddError(
                    eErrors.Err_Code.ToString()
                    , "Duplicate Item No. found. Please change the Item No.");;
            }

            if (Do_Methods.Convert_String(Obj.pDr_RowProperty["Name"]) != "")
            {
                base.AddError(
                    eErrors.Err_Name.ToString()
                    , "Item Name is required.");
            }

            return(base.mList_ValidationError.Count == 0);
        }
        public override bool Save(DataObjects_Framework.DataAccess.Interface_DataAccess Da = null)
        {
            DateTime ServerDate = Layer02_Common.GetServerDate();

            if (Convert.ToInt64(Do_Methods.IsNull(this.mHeader_Dr[this.mHeader_TableName + "ID"], 0)) == 0)
            {
                this.mHeader_Dr["EmployeeID_CreatedBy"] = this.mCurrentUser.pDrUser["EmployeeID"];
                this.mHeader_Dr["DateCreated"]          = ServerDate;
            }

            this.mHeader_Dr["EmployeeID_UpdatedBy"] = this.mCurrentUser.pDrUser["EmployeeID"];
            this.mHeader_Dr["DateUpdated"]          = ServerDate;

            return(base.Save(Da));
        }
        bool Save_Validation(System.Text.StringBuilder Sb_Msg)
        {
            bool       IsValid = true;
            WebControl Wc;

            Wc = this.Txt_Username;
            Layer01_Methods_Web.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , Layer01_Constants_Web.CnsCssTextbox
                , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                , (this.Txt_Username.Text != "")
                , "User Name is required. <br />");

            Wc = this.Txt_Username;
            Layer01_Methods_Web.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , Layer01_Constants_Web.CnsCssTextbox
                , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                , (!Layer02_Common.CheckSeriesDuplicate("User", "UserName", this.mObj.GetKeys(), this.Txt_Username.Text))
                , "User Name is required. <br />");

            this.Txt_Password.CssClass        = Layer01_Constants_Web.CnsCssTextbox;
            this.Txt_ConfirmPassword.CssClass = Layer01_Constants_Web.CnsCssTextbox;

            if (this.Txt_Password.Text.Trim() != "")
            {
                if (this.Txt_Password.Text != this.Txt_ConfirmPassword.Text)
                {
                    IsValid = false;
                    this.Txt_Password.CssClass        = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                    this.Txt_ConfirmPassword.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                    Sb_Msg.Append("Please confirm your password. <br />");
                }
            }

            return(IsValid);
        }
        //[-]

        public void UpdatePriceHistory(DataRow[] ArrDr_Item)
        {
            DateTime ServerDate = Layer02_Common.GetServerDate();

            PreparedQuery Pq = Do_Methods.CreateDataAccess().CreatePreparedQuery();

            Pq.pQuery = @"Insert Into Item_PriceHistory (ItemID, Price, EmployeeID_PostedBy, DatePosted) Values (@ItemID, @Price, @EmployeeID_PostedBy, @DatePosted)";

            Pq.Add_Parameter("ItemID", Do_Constants.eParameterType.Long);
            Pq.Add_Parameter("EmployeeID_PostedBy", Do_Constants.eParameterType.Long, this.mCurrentUser.pDrUser["EmployeeID"]);
            Pq.Add_Parameter("DatePosted", Do_Constants.eParameterType.DateTime, ServerDate);
            Pq.Add_Parameter("Price", Do_Constants.eParameterType.Numeric, null, 0, 18, 2);

            Pq.Prepare();

            foreach (DataRow Dr in ArrDr_Item)
            {
                Pq.pParameter_Set("ItemID", Dr["ItemID"]);
                Pq.pParameter_Set("Price", Dr["Price"]);
                Pq.ExecuteNonQuery();
            }
        }
        bool Save_Validation(ref System.Text.StringBuilder Sb_Msg)
        {
            WebControl Wc;
            bool       IsValid = true;

            this.Txt_EmployeeCode.CssClass = Layer01_Constants_Web.CnsCssTextbox;
            if (this.Txt_EmployeeCode.Text.Trim() == "")
            {
                this.Txt_EmployeeCode.Text = Layer02_Common.GetSeriesNo("Item");
            }

            Wc = this.Txt_EmployeeCode;
            ClsBasePageDetails.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , Layer01_Constants_Web.CnsCssTextbox
                , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                , (Layer02_Common.CheckSeriesDuplicate("uvw_Employee", "EmployeeCode", this.mObj.GetKeys(), this.Txt_EmployeeCode.Text))
                , "Duplicate Employee ID found. Please change the Employee ID." + "<br />");

            Wc = null;
            ClsBasePageDetails.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , string.Empty
                , string.Empty
                , (this.EODtp_DateHired.SelectedDate == null)
                , "Hired Date is required" + "<br />");

            if (!this.UcPerson.Update_Validate(ref Sb_Msg))
            {
                IsValid = false;
            }

            return(IsValid);
        }
        public bool Save(eSaveAction SaveAction = eSaveAction.Save)
        {
            bool IsSave = false;

            if (this.mCurrentUser == null)
            {
                throw new Exception("User is not initialized");
            }

            Interface_DataAccess Da = this.mDa;

            try
            {
                Da.Connect();
                Da.BeginTransaction();

                DateTime ServerDate = Layer02_Common.GetServerDate(Da);

                switch (SaveAction)
                {
                case eSaveAction.Save:
                    if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsCancelled"], false))
                    {
                        throw new Exception("Document is already cancelled.");
                    }
                    if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsPosted"], false))
                    {
                        throw new Exception("Document is already posted.");
                    }
                    break;

                case eSaveAction.Post:
                    if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsPosted"], false))
                    {
                        throw new Exception("Document is already posted.");
                    }
                    this.mHeader_Dr["IsPosted"]            = true;
                    this.mHeader_Dr["DatePosted"]          = ServerDate;
                    this.mHeader_Dr["EmployeeID_PostedBy"] = this.mCurrentUser.pDrUser["EmployeeID"];
                    break;

                case eSaveAction.Cancel:
                    if ((bool)Do_Methods.IsNull(this.mHeader_Dr["IsCancelled"], false))
                    {
                        throw new Exception("Document is already cancelled.");
                    }
                    this.mHeader_Dr["IsCancelled"]            = true;
                    this.mHeader_Dr["DateCancelled"]          = ServerDate;
                    this.mHeader_Dr["EmployeeID_CancelledBy"] = this.mCurrentUser.pDrUser["EmployeeID"];
                    break;
                }

                Da.SaveDataRow(this.mHeader_Dr, this.mHeader_TableName);
                Da.CommitTransaction();
                IsSave = true;
            }
            catch (Exception ex)
            {
                Da.RollbackTransaction();
                throw ex;
            }
            finally
            { Da.Close(); }

            return(IsSave);
        }
示例#9
0
        bool Save_Validation(ref System.Text.StringBuilder Sb_Msg)
        {
            WebControl Wc;
            bool       IsValid = true;

            this.Txt_Code.CssClass = Layer01_Constants_Web.CnsCssTextbox;
            if (this.Txt_Code.Text.Trim() == "")
            {
                this.Txt_Code.Text = Layer02_Common.GetSeriesNo("Customer");
            }

            Wc = this.Txt_Code;
            Layer01_Methods_Web.Save_Validation(
                ref Sb_Msg
                , ref Wc
                , ref IsValid
                , Layer01_Constants_Web.CnsCssTextbox
                , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                , Layer02_Common.CheckSeriesDuplicate("uvw_Customer", "CustomerCode", this.mObj.GetKeys(), this.Txt_Code.Text)
                , "Duplicate Customer ID found. Please change the Customer ID. <br />");

            Int64     LookupClientTypeID = Convert.ToInt64(Do_Methods.IsNull(this.mObj.pDr["LookupClientTypeID"], 0));
            DataTable Dt = Do_Methods_Query.GetQuery("LookupClientType", "", "LookupClientTypeID = " + LookupClientTypeID.ToString());

            if (Dt.Rows.Count > 0)
            {
                DataRow Dr_ClientType = Dt.Rows[0];

                if ((bool)Do_Methods.IsNull(Dr_ClientType["IsCurrency"], false))
                {
                    Wc = this.Cbo_Currency;
                    Layer01_Methods_Web.Save_Validation(
                        ref Sb_Msg
                        , ref Wc
                        , ref IsValid
                        , Layer01_Constants_Web.CnsCssTextbox
                        , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                        , (Convert.ToInt64(this.Cbo_Currency.SelectedValue) == 0)
                        , "Currency is required. <br />");
                }

                if ((bool)Do_Methods.IsNull(Dr_ClientType["IsCreditCard_AccountName"], false))
                {
                    Wc = this.Txt_CreditCard_AccountName;
                    Layer01_Methods_Web.Save_Validation(
                        ref Sb_Msg
                        , ref Wc
                        , ref IsValid
                        , Layer01_Constants_Web.CnsCssTextbox
                        , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                        , (this.Txt_CreditCard_AccountName.Text == "")
                        , "Account Name is required. <br />");
                }

                if ((bool)Do_Methods.IsNull(Dr_ClientType["IsCreditCard"], false))
                {
                    bool Inner_IsValid = true;
                    this.Txt_CreditCard_Part1.CssClass = Layer01_Constants_Web.CnsCssTextbox;
                    this.Txt_CreditCard_Part2.CssClass = Layer01_Constants_Web.CnsCssTextbox;
                    this.Txt_CreditCard_Part3.CssClass = Layer01_Constants_Web.CnsCssTextbox;
                    this.Txt_CreditCard_Part4.CssClass = Layer01_Constants_Web.CnsCssTextbox;

                    if (this.Txt_CreditCard_Part1.Text.Trim() == "")
                    {
                        Inner_IsValid = false;
                    }
                    if (this.Txt_CreditCard_Part2.Text.Trim() == "")
                    {
                        Inner_IsValid = false;
                    }
                    if (this.Txt_CreditCard_Part3.Text.Trim() == "")
                    {
                        Inner_IsValid = false;
                    }
                    if (this.Txt_CreditCard_Part4.Text.Trim() == "")
                    {
                        Inner_IsValid = false;
                    }

                    if (!Inner_IsValid)
                    {
                        IsValid = false;
                        this.Txt_CreditCard_Part1.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        this.Txt_CreditCard_Part2.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        this.Txt_CreditCard_Part3.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        this.Txt_CreditCard_Part4.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        Sb_Msg.Append("Credit Card is required. <br />");
                    }
                }


                Int32 CreditCardExpiration_Month = 0;
                Int32 CreditCardExpiration_Year  = 0;

                try
                {
                    Int32.TryParse(this.Txt_CreditCardExpiration_Month.Text, out CreditCardExpiration_Month);
                    if (this.Txt_CreditCardExpiration_Year.Text.Trim() != "")
                    {
                        Int32.TryParse("20" + this.Txt_CreditCardExpiration_Year.Text, out CreditCardExpiration_Year);
                    }
                }
                catch { }

                this.Txt_CreditCardExpiration_Month.CssClass = Layer01_Constants_Web.CnsCssTextbox;
                this.Txt_CreditCardExpiration_Year.CssClass  = Layer01_Constants_Web.CnsCssTextbox;

                if (!
                    (this.Txt_CreditCardExpiration_Month.Text.Trim() == "" ||
                     this.Txt_CreditCardExpiration_Year.Text.Trim() == ""))
                {
                    DateTime Inner_DateTime;
                    try
                    {
                        Inner_DateTime = new DateTime(CreditCardExpiration_Year, CreditCardExpiration_Month, 1);
                        if (Inner_DateTime < DateTime.Now)
                        {
                            IsValid = false;
                            this.Txt_CreditCardExpiration_Month.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                            this.Txt_CreditCardExpiration_Year.CssClass  = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                            Sb_Msg.Append("Credit Card Date Expiry must be earlier than today. <br />");
                        }
                    }
                    catch
                    {
                        IsValid = false;
                        this.Txt_CreditCardExpiration_Month.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        this.Txt_CreditCardExpiration_Year.CssClass  = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        Sb_Msg.Append("Credit Card Date Expiry is incorrect. <br />");
                    }
                }

                if ((bool)Do_Methods.IsNull(Dr_ClientType["IsCreditCard_Expiration"], false))
                {
                    if (this.Txt_CreditCardExpiration_Month.Text.Trim() == "" ||
                        this.Txt_CreditCardExpiration_Year.Text.Trim() == "")
                    {
                        IsValid = false;
                        this.Txt_CreditCardExpiration_Month.CssClass = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        this.Txt_CreditCardExpiration_Year.CssClass  = Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight;
                        Sb_Msg.Append("Credit Card Date Expiry is required. <br />");
                    }
                }

                if ((bool)Do_Methods.IsNull(Dr_ClientType["IsPaymentTerm"], false))
                {
                    Wc = this.Cbo_PaymentTerm;
                    Layer01_Methods_Web.Save_Validation(
                        ref Sb_Msg
                        , ref Wc
                        , ref IsValid
                        , Layer01_Constants_Web.CnsCssTextbox
                        , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                        , (Convert.ToInt64(this.Cbo_PaymentTerm.SelectedValue) == 0)
                        , "Payment Term is required. <br />");
                }

                if ((bool)Do_Methods.IsNull(Dr_ClientType["IsTaxCode"], false))
                {
                    Wc = this.Cbo_TaxCode;
                    Layer01_Methods_Web.Save_Validation(
                        ref Sb_Msg
                        , ref Wc
                        , ref IsValid
                        , Layer01_Constants_Web.CnsCssTextbox
                        , Layer01_Constants_Web.CnsCssTextbox_ValidateHighlight
                        , (Convert.ToInt64(this.Cbo_TaxCode.SelectedValue) == 0)
                        , "Tax Code is required. <br />");
                }
            }

            return(IsValid);
        }