Пример #1
0
        void Update()
        {
            DataRow[] ArrDr            = this.mObj_ContactPerson.pDt_ContactPerson.Select("TmpKey = " + this.mTmpKey, "", DataViewRowState.CurrentRows);
            DataRow   Dr_ContactPerson = null;

            if (ArrDr.Length > 0)
            {
                Dr_ContactPerson = ArrDr[0];
            }
            else
            {
                //Int64 TmpKey = 0;
                //ArrDr = this.mObj_ContactPerson.pDt_ContactPerson.Select("", "TmpKey Desc", DataViewRowState.CurrentRows);
                //if (ArrDr.Length > 0)
                //{ TmpKey = System.Convert.ToInt64(ArrDr[0]["TmpKey"]); }
                //TmpKey++;

                //Dr_ContactPerson = this.mObj_ContactPerson.pDt_ContactPerson.NewRow();
                //Dr_ContactPerson["TmpKey"] = TmpKey;
                //this.mObj_ContactPerson.pDt_ContactPerson.Rows.Add(Dr_ContactPerson);
                //this.mObj_ContactPerson.pBO_ContactPerson_Persons.Add(TmpKey.ToString(), this.mObj_Person);

                Dr_ContactPerson = this.mObj_ContactPerson.pObj_ContactPerson_Details.Add_Item();
            }

            this.UcPerson.Update();

            Dr_ContactPerson["Position"]  = this.Txt_Position.Text;
            Dr_ContactPerson["FullName"]  = Do_Methods.IsNull(this.mObj_Person.pDr["FullName"], "");
            Dr_ContactPerson["Phone"]     = Do_Methods.IsNull(this.mObj_Person.pDr["Phone"], "");
            Dr_ContactPerson["Mobile"]    = Do_Methods.IsNull(this.mObj_Person.pDr["Mobile"], "");
            Dr_ContactPerson["Fax"]       = Do_Methods.IsNull(this.mObj_Person.pDr["Fax"], "");
            Dr_ContactPerson["Email"]     = Do_Methods.IsNull(this.mObj_Person.pDr["Email"], "");
            Dr_ContactPerson["WorkEmail"] = Do_Methods.IsNull(this.mObj_Person.pDr["WorkEmail"], "");

            Do_Methods.ConvertCaps(Dr_ContactPerson);
            this.mTmpKey = System.Convert.ToInt64(Do_Methods.IsNull(Dr_ContactPerson["TmpKey"], 0));

            if (EvAccept != null)
            {
                EvAccept();
            }
        }
        Int64 List_Count(QueryCondition Condition = null)
        {
            DataRow Dr_Bind = Do_Methods_Query.GetSystemBindDefinition(this.mSelectionName);

            string Bind_Desc      = (string)Do_Methods.IsNull(Dr_Bind["Desc"], "");
            string Bind_TableName = (string)Do_Methods.IsNull(Dr_Bind["TableName"], "");
            string Bind_TableKey  = (string)Do_Methods.IsNull(Dr_Bind["TableKey"], "");
            string Bind_Condition = (string)Do_Methods.IsNull(Dr_Bind["Condition"], "");
            string Bind_Sort      = (string)Do_Methods.IsNull(Dr_Bind["Sort"], "");

            string Query_Source    = "";
            string Query_Condition = "";

            if (this.mQuery_Selection != "")
            {
                Query_Condition = this.mQuery_Selection;
            }
            else
            {
                Query_Source = Bind_TableName;
                if (Bind_Condition != "")
                {
                    Query_Condition = "Where " + Bind_Condition;
                }
            }

            if (Query_Source == "")
            {
                throw new Exception("Selection Source not set.");
            }

            string    Query   = @"(Select * From " + Query_Source + " " + Query_Condition + @") As [Tb]";
            DataTable Dt_List = Do_Methods_Query.GetQuery(Query, "Count(1) As [Ct]", Condition);

            Int64 Rv = 0;

            try
            { Rv = Convert.ToInt64(Do_Methods.IsNull(Dt_List.Rows[0]["Ct"], 0)); }
            catch { }

            return(Rv);
        }
        public void Save_ReloadPage()
        {
            this.Session.Remove(this.mObjID);

            Collection PageCollection = new Collection();

            PageCollection.Add(true, "IsSave");

            this.Session[Layer01_Constants_Web.CnsSession_TmpObj] = PageCollection;
            this.Session[Layer01_Constants_Web.CnsSession_Keys]   = this.mObj_Base.GetKeys();

            DataTable Dt  = Do_Methods_Query.GetQuery("System_Modules", "", "System_ModulesID = " + this.mSystem_ModulesID.ToString());
            string    Url = "";

            if (Dt.Rows.Count > 0)
            {
                Url = "~/" + (string)Do_Methods.IsNull(Dt.Rows[0]["PageUrl_Details"], "");
            }

            this.Response.Redirect(Url);
        }
        void Details_SelectPdfOthers(string SelectedFile)
        {
            System.IO.FileInfo Fi = new System.IO.FileInfo(SelectedFile);

            this.mObj.pDr["PdfOthers_Path"] = Fi.Name;

            if ((string)Do_Methods.IsNull(this.mObj.pDr["PdfOthers_Path"], "") == "")
            {
                this.Btn_PdfOther.CssClass = Layer01_Constants_Web.CnsCssControlEnabledFalse;
                this.Btn_PdfOther.Enabled  = false;
            }
            else
            {
                this.Btn_PdfOther.CssClass = Layer01_Constants_Web.CnsCssControlEnabled;
                this.Btn_PdfOther.Enabled  = true;
            }

            try
            { this.EOCbp_PdfOther.Update(); }
            catch { }
        }
Пример #5
0
        //[-]

        protected string Details_PrepareNew()
        {
            DataTable Dt  = Do_Methods_Query.GetQuery("System_Modules", "", "System_ModulesID = " + this.mSystem_ModulesID.ToString());
            string    Url = "";

            if (Dt.Rows.Count > 0)
            {
                Url = "~/" + (string)Do_Methods.IsNull(Dt.Rows[0]["PageUrl_Details"], "");
            }

            string Override_PageUrl_Details_New = (string)this.ViewState[CnsOverride_PageUrl_Details_New];

            if (Override_PageUrl_Details_New != "")
            {
                Url = Override_PageUrl_Details_New;
            }

            this.Session[Layer01_Constants_Web.CnsSession_Keys] = null;

            return(Url);
        }
Пример #6
0
        //[-]

        protected DataTable List(
            QueryCondition Condition = null
            , string Sort            = ""
            , Int64 Top  = 0
            , Int32 Page = 0)
        {
            DataRow Dr_Bind        = Do_Methods_Query.GetSystemBindDefinition(this.mSystem_BinDefinition_Name);
            string  Bind_Condition = (string)Do_Methods.IsNull(Dr_Bind["Condition"], "");
            string  Bind_Sort      = (string)Do_Methods.IsNull(Dr_Bind["Sort"], "");

            string Query_Condition = "";

            if (Bind_Condition.Trim() != "")
            {
                Query_Condition = " Where " + Bind_Condition;
            }

            string Source = (string)this.ViewState[CnsSource];

            if (Source == "")
            {
                Source = this.mObj_Base.pHeader_ViewName;
            }

            if (Sort == "")
            {
                Sort = Bind_Sort;
            }

            string Query_Table = @"(Select * From " + Source + " " + Query_Condition + " ) As [Tb]";

            Interface_DataAccess Da = this.mObj_Base.CreateDataAccess();

            //DataTable Dt = Do_Methods_Query.GetQuery(Query_Table, "", Condition, Sort, Top, Page);
            DataTable Dt = Da.GetQuery(Query_Table, "", Condition, Sort, Top, Page);

            Da.Close();

            return(Dt);
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Btn_Logout.Click += Btn_Logout_Click;

            try
            {
                if (this.pMaster.pCurrentUser == null)
                {
                    return;
                }
                if (!this.pMaster.pCurrentUser.pIsLoggedIn)
                {
                    return;
                }
                if (!this.IsPostBack)
                {
                    this.LoadMenu();
                    this.Lbl_Name.Text = (string)Do_Methods.IsNull(this.pMaster.pCurrentUser.pDrUser["EmployeeName"], "");
                }
            }
            catch { }
        }
        public override void Load(Keys Keys = null)
        {
            base.Load(Keys);

            //[-]

            Int64 ContactPersonID = Convert.ToInt64(Do_Methods.IsNull(this.pDr["ContactPersonID"], 0));

            if (ContactPersonID != 0)
            {
                Keys = new Keys();
                Keys.Add("ContactPersonID", ContactPersonID);
            }
            else
            {
                Keys = null;
            }

            this.mObj_ContactPerson.Load(Keys);

            //this.mObj_ShippingAddress.Load(Keys, this);

            //[-]

            //foreach (DataRow Dr in this.pDt_ShippingAddress.Rows)
            //{
            //    ClsAddress Inner_Obj = new ClsAddress(this.mCurrentUser);
            //    Keys Inner_Keys = null;
            //    Int64 Inner_ID = Convert.ToInt64(Do_Methods.IsNull(Dr["AddressID"], 0));
            //    if (Inner_ID != 0)
            //    {
            //        Inner_Keys = new Keys();
            //        Inner_Keys.Add("AddressID", Inner_ID);
            //    }
            //    Inner_Obj.Load(Inner_Keys);
            //    this.mBO_ShippingAddress_Address.Add(Convert.ToInt64(Do_Methods.IsNull(Dr["TmpKey"], 0)).ToString(), Inner_Obj);
            //}
        }
Пример #9
0
        void BindGrid_Details_Filter()
        {
            DataTable Dt_FilterFields = (this.ViewState[CnsDt_FilterFields] != null) ? (DataTable)this.ViewState[CnsDt_FilterFields] : null;
            string    FilterText      = "";

            DataRow[] ArrDr = Dt_FilterFields.Select("Field = '" + this.Cbo_SearchFilter.SelectedValue + "'");
            if (ArrDr.Length > 0)
            {
                Type Inner_DataType = Type.GetType(Do_Methods.Convert_String(ArrDr[0]["DataType"]));

                //FilterText = Do_Methods.PrepareFilterText(
                //    (string)Do_Methods.IsNull(ArrDr[0]["Field"], "")
                //    , (string)Do_Methods.IsNull(ArrDr[0]["DataType"], "")
                //    , this.Txt_Search.Text);

                FilterText = Do_Methods.PrepareFilterText(
                    (string)Do_Methods.IsNull(ArrDr[0]["Field"], "")
                    , Inner_DataType
                    , this.Txt_Search.Text);
            }

            this.UcGrid_Details.pDt_Source.DefaultView.RowFilter = FilterText;
        }
Пример #10
0
        protected string Details_PrepareOpen(Int64 ID)
        {
            DataTable Dt  = Do_Methods_Query.GetQuery("System_Modules", "", "System_ModulesID = " + this.mSystem_ModulesID.ToString());
            string    Url = "";

            if (Dt.Rows.Count > 0)
            {
                Url = "~/" + (string)Do_Methods.IsNull(Dt.Rows[0]["PageUrl_Details"], "");
            }

            this.Session[Layer01_Constants_Web.CnsSession_Keys] = null;

            QueryCondition Qc = new QueryCondition();

            Qc.Add(this.mObj_Base.pHeader_TableKey, "=", ID, typeof(Int64).ToString());
            Dt = this.List(Qc);
            if (Dt.Rows.Count > 0)
            {
                this.Session[Layer01_Constants_Web.CnsSession_Keys] = this.mObj_Base.GetKeys(Dt.Rows[0]);
            }

            return(Url);
        }
Пример #11
0
        void SetupPage()
        {
            DataRow[] ArrDr            = this.mObj_ContactPerson.pDt_ContactPerson.Select("TmpKey = " + this.mTmpKey);
            DataRow   Dr_ContactPerson = null;

            if (ArrDr.Length > 0)
            {
                Dr_ContactPerson = ArrDr[0];
            }
            else
            {
                this.mTmpKey = 0;
            }

            //string Title = "";
            if (this.mTmpKey == 0)
            {
                //Title = "Add Contact Person";
                this.Txt_Position.Text = "";
                this.mObj_Person       = new ClsPerson(this.mObj_ContactPerson.pCurrentUser);
                this.mObj_Person.Load();
            }
            else
            {
                //Title = "Update Contact Person";
                this.Txt_Position.Text = (string)Do_Methods.IsNull(Dr_ContactPerson["Position"], "");
                //this.mObj_Person = (ClsPerson)this.mObj_ContactPerson.pBO_ContactPerson_Persons[this.mTmpKey.ToString()];
                this.mObj_Person = this.mObj_ContactPerson.pObj_ContactPerson_Details.pObj_Person_Get(this.mTmpKey);
            }

            this.UcPerson.Setup(this.mObj_Person);
            this.Session[this.mObjID + CnsObj_Person] = this.mObj_Person;

            try
            { this.EOCbp_Dialog_ContactPerson.Update(); }
            catch { }
        }
Пример #12
0
        public static string GetSeriesNo(string Name)
        {
            string    Rv = "";
            DataTable Dt;
            string    TableName;
            string    FieldName;
            string    Prefix;
            Int32     Digits;

            Dt = Do_Methods_Query.GetQuery("System_DocumentSeries", "", "ModuleName = '" + Name + "'");
            if (Dt.Rows.Count > 0)
            {
                TableName = (string)Do_Methods.IsNull(Dt.Rows[0]["TableName"], "");
                FieldName = (string)Do_Methods.IsNull(Dt.Rows[0]["FieldName"], "");
                Prefix    = (string)Do_Methods.IsNull(Dt.Rows[0]["Prefix"], "");
                Digits    = (Int32)Do_Methods.IsNull(Dt.Rows[0]["Digits"], "");
            }
            else
            {
                return(Rv);
            }

            List <QueryParameter> Sp = new List <QueryParameter>();

            Sp.Add(new QueryParameter("@TableName", TableName));
            Sp.Add(new QueryParameter("@FieldName", FieldName));
            Sp.Add(new QueryParameter("@Prefix", Prefix));
            Sp.Add(new QueryParameter("@Digits", Digits));

            Dt = Do_Methods_Query.ExecuteQuery("usp_GetSeriesNo", Sp).Tables[0];
            if (Dt.Rows.Count > 0)
            {
                Rv = (string)Dt.Rows[0][0];
            }

            return(Rv);
        }
        //[-]

        void Handle_Selection(DataTable Dt, EO.Web.CallbackEventArgs e, string Data)
        {
            Int64 ID = 0;

            if (Dt.Rows.Count > 0)
            {
                ID = (Int64)Do_Methods.IsNull(Dt.Rows[0]["ID"], 0);
            }

            System.Text.StringBuilder Sb_Js = new System.Text.StringBuilder();

            if (Data == this.Btn_AddItemPart.ID)
            {
                this.Details_AddItemPart(Dt);
            }
            else if (Data == this.Btn_AddItemLocation.ID)
            {
                this.Details_AddItemLocation(Dt);
            }
            if (Data == this.Btn_AddItemSupplier.ID)
            {
                this.Details_AddItemSupplier(Dt);
            }
        }
Пример #14
0
        public static List <ClsBindGridColumn> GetBindGridColumn(string Name)
        {
            List <ClsBindGridColumn> List_Gc = new List <ClsBindGridColumn>();
            ClsBindGridColumn        Gc;

            DataTable Dt_Def = Do_Methods_Query.GetQuery(@"udf_System_BindDefinition('" + Name + "')", "", "", "OrderIndex");

            foreach (DataRow Dr in Dt_Def.Rows)
            {
                Gc = new ClsBindGridColumn(
                    (string)Do_Methods.IsNull(Dr["Name"], "")
                    , (string)Do_Methods.IsNull(Dr["Desc"], "")
                    , (Int32)Do_Methods.IsNull(Dr["Width"], 0)
                    , (string)Do_Methods.IsNull(Dr["NumberFormat"], "")
                    , (Layer01_Common.Common.Layer01_Constants.eSystem_Lookup_FieldType)Do_Methods.IsNull(Dr["System_LookupID_FieldType"], Layer01_Common.Common.Layer01_Constants.eSystem_Lookup_FieldType.FieldType_Static)
                    , !(bool)Do_Methods.IsNull(Dr["IsHidden"], false)
                    , !(bool)Do_Methods.IsNull(Dr["IsReadOnly"], false));

                Gc.mButtonType = (ButtonColumnType)Do_Methods.IsNull(Dr["System_LookupID_ButtonType"], ButtonColumnType.LinkButton);
                Gc.mFieldText  = (string)Do_Methods.IsNull(Dr["FieldText"], "");

                List_Gc.Add(Gc);
            }

            return(List_Gc);
        }
Пример #15
0
        void AddNode(ref DataTable Dt_Menu, TreeNode TvNode, Int64 System_ModulesID)
        {
            DataRow[] ArrDr = Dt_Menu.Select("Parent_System_ModulesID = " + System_ModulesID.ToString());
            foreach (DataRow Dr in ArrDr)
            {
                TreeNode Node = new TreeNode();
                Node.Text = @"&nbsp;" + Dr["Name"];

                if ((string)Do_Methods.IsNull(Dr["PageUrl_List"], "") != "")
                {
                    string Arguments = (string)Do_Methods.IsNull(Dr["Arguments"], "");
                    if (Arguments != "")
                    {
                        Arguments = @"?" + Arguments;
                    }
                    Node.NavigateUrl = @"~/" + (string)Dr["PageUrl_List"] + Arguments;
                }
                else
                {
                    Node.SelectAction = TreeNodeSelectAction.None;
                }

                TvNode.ChildNodes.Add(Node);

                DataRow[] Inner_ArrDr = Dt_Menu.Select("Parent_System_ModulesID = " + ((Int64)Do_Methods.IsNull(Dr["System_ModulesID"], 0)).ToString());
                if (Inner_ArrDr.Length > 0)
                {
                    this.AddNode(ref Dt_Menu, Node, (Int64)Do_Methods.IsNull(Dr["System_ModulesID"], 0));
                }
            }
        }
Пример #16
0
        string Details_TaxCode()
        {
            System.Text.StringBuilder Sb_Js = new System.Text.StringBuilder();
            Int64 LookupTaxCodeID           = 0;

            try
            { LookupTaxCodeID = Convert.ToInt64(this.Cbo_TaxCode.SelectedValue); }
            catch { }

            DataTable Dt = Do_Methods_Query.GetQuery("LookupTaxCode", "", "LookupTaxCodeID = " + LookupTaxCodeID);

            if (Dt.Rows.Count > 0)
            {
                DataRow Dr = Dt.Rows[0];
                Layer01_Methods_Web.Eval_AppendJs(this.Server, ref Sb_Js, this.Lbl_PST_Value.ClientID, "innerHTML", Strings.Format(Do_Methods.IsNull(Dr["PST_Value"], 0), "#,##0.00"));
                Layer01_Methods_Web.Eval_AppendJs(this.Server, ref Sb_Js, this.Lbl_GST_Value.ClientID, "innerHTML", Strings.Format(Do_Methods.IsNull(Dr["GST_Value"], 0), "#,##0.00"));
                Layer01_Methods_Web.Eval_AppendJs(this.Server, ref Sb_Js, this.Lbl_HST_Value.ClientID, "innerHTML", Strings.Format(Do_Methods.IsNull(Dr["HST_Value"], 0), "#,##0.00"));
            }
            return(Sb_Js.ToString());
        }
Пример #17
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);
        }
        public void Setup(
            string Name
            , DataTable Dt
            , string Key      = ""
            , bool AllowSort  = false
            , bool HasDelete  = false
            , bool IsReadOnly = false)
        {
            ClsSysCurrentUser Obj_CurrentUser = (ClsSysCurrentUser)this.Session[Layer01_Constants_Web.CnsSession_CurrentUser];

            this.mObjID     = Obj_CurrentUser.GetNewPageObjectID();
            this.mDt_Source = Dt;

            this.ViewState[CnsObjID] = this.mObjID;
            this.Session[this.mObjID + CnsDt_Source] = this.mDt_Source;

            //[-]

            DataRow Dr_Bind       = Do_Methods_Query.GetSystemBindDefinition(Name);
            string  Bind_TableKey = (string)Do_Methods.IsNull(Dr_Bind["TableKey"], "");
            List <ClsBindGridColumn_EO> List_Gc = Layer01_Methods_Web_EO.GetBindGridColumn_EO(Name);

            foreach (ClsBindGridColumn_EO Gc in List_Gc)
            {
                if (Gc.mEnabled)
                {
                    Gc.mEnabled = !IsReadOnly;
                }
            }

            if (!IsReadOnly)
            {
                if (HasDelete)
                {
                    ClsBindGridColumn_EO Gc =
                        new ClsBindGridColumn_EO(
                            ""
                            , ""
                            , 80
                            , ""
                            , Layer01_Common.Common.Layer01_Constants.eSystem_Lookup_FieldType.FieldType_Delete);
                    Gc.mFieldText           = "Delete";
                    Gc.mClientSideBeginEdit = "EOGrid_RowEdit";
                    List_Gc.Add(Gc);
                }
            }

            if (Key.Trim() == "")
            {
                Key = Bind_TableKey;
            }

            this.EOGrid_List.EnableKeyboardNavigation = true;
            this.EOGrid_List.StyleSetIDField          = "Item_Style";
            Layer01_Methods_Web_EO.BindEOGrid(ref this.EOGrid_List, Dt, List_Gc, Key, AllowSort);

            this.ViewState[CnsKey]       = Key;
            this.ViewState[CnsHasDelete] = HasDelete;

            //[-]

            this.Page_Load(null, null);
        }
        void EOCb_View_Execute(object sender, EO.Web.CallbackEventArgs e)
        {
            string Url = "";

            if (e.Parameter == this.Btn_PdfDesc.ID)
            {
                Url = Layer01_Constants_Web.CnsPdfPath + HttpUtility.UrlPathEncode((string)Do_Methods.IsNull(this.mObj.pDr["PdfDesc_Path"], ""));
            }
            else if (e.Parameter == this.Btn_PdfFaq.ID)
            {
                Url = Layer01_Constants_Web.CnsPdfPath + HttpUtility.UrlPathEncode((string)Do_Methods.IsNull(this.mObj.pDr["PdfFaq_Path"], ""));
            }
            else if (e.Parameter == this.Btn_PdfFaq.ID)
            {
                Url = Layer01_Constants_Web.CnsPdfPath + HttpUtility.UrlPathEncode((string)Do_Methods.IsNull(this.mObj.pDr["PdfOthers_Path"], ""));
            }
            else if (e.Parameter == this.Btn_ViewImage.ID)
            {
                Url = Layer01_Constants_Web.CnsImagePath + HttpUtility.UrlPathEncode((string)Do_Methods.IsNull(this.mObj.pDr["Image_Path"], ""));
            }

            e.Data = this.Page.ResolveUrl(Url);
        }
Пример #20
0
        private void LoadMenu()
        {
            ClsSysCurrentUser CurrentUser = this.mMaster.pCurrentUser;
            DataTable         Dt_Menu;

            if (CurrentUser.pIsAdmin)
            {
                Dt_Menu = Do_Methods_Query.GetQuery("uvw_System_Modules", "", "IsNull(IsHidden,0) = 0", "Parent_OrderIndex, OrderIndex");
            }
            else
            {
                List <QueryParameter> Sp = new List <QueryParameter>();
                Sp.Add(new QueryParameter(@"@UserID", CurrentUser.pDrUser["UserID"]));
                Dt_Menu = Do_Methods_Query.ExecuteQuery("usp_System_Modules_Load", Sp).Tables[0];
            }

            this.trvMenus.Nodes.Clear();

            foreach (DataRow Dr in Dt_Menu.Rows)
            {
                if ((Int64)Do_Methods.IsNull(Dr["Parent_System_ModulesID"], 0) == 0)
                {
                    TreeNode Node = new TreeNode();
                    Node.Text = @"&nbsp" + Dr["Name"];
                    //Node.ImageUrl = "";
                    if ((string)Do_Methods.IsNull(Dr["PageUrl_List"], "") != "")
                    {
                        string Arguments = (string)Do_Methods.IsNull(Dr["Arguments"], "");
                        if (Arguments != "")
                        {
                            Arguments = @"?" + Arguments;
                        }
                        Node.NavigateUrl = @"~/" + Dr["PageUrl_List"] + Arguments;
                    }
                    else
                    {
                        Node.SelectAction = TreeNodeSelectAction.None;
                    }

                    this.trvMenus.Nodes.Add(Node);

                    DataRow[] ArrDr = Dt_Menu.Select("Parent_System_ModulesID = " + ((Int64)Do_Methods.IsNull(Dr["System_ModulesID"], 0)).ToString());
                    if (ArrDr.Length > 0)
                    {
                        this.AddNode(ref Dt_Menu, Node, (Int64)Do_Methods.IsNull(Dr["System_ModulesID"], 0));
                    }
                }
            }
        }
        public static void PostEOGrid(
            ref EO.Web.Grid EOGrid
            , DataTable Dt
            , string KeyField
            , bool HasDelete = true)
        {
            DataTable Dt_DeletedKeys = new DataTable();

            Dt_DeletedKeys.Columns.Add("Key", typeof(Int64));

            List <Int64> List_DeletedKeys = new List <long>();


            foreach (EO.Web.GridItem Gi in EOGrid.Items)
            {
                Int64     Key   = (Int64)Do_Methods.IsNull(Gi.Key, 0);
                DataRow[] ArrDr = Dt.Select(KeyField + " = " + Key);
                DataRow   Dr;

                if (Gi.Deleted)
                {
                    if (Key > 0)
                    {
                        List_DeletedKeys.Add(Key);
                    }
                    continue;
                }

                if (ArrDr.Length > 0)
                {
                    Dr = ArrDr[0];
                }
                else
                {
                    Int64     Ct          = 0;
                    DataRow[] Inner_ArrDr = Dt.Select("", KeyField + " Desc");
                    if (Inner_ArrDr.Length > 0)
                    {
                        Ct = (Int64)Inner_ArrDr[0][KeyField];
                    }
                    Ct++;
                    Dr           = Dt.NewRow();
                    Dr[KeyField] = Ct;
                    Dt.Rows.Add(Dr);
                }

                foreach (EO.Web.GridCell Cell in Gi.Cells)
                {
                    if (Cell.Column.ReadOnly)
                    {
                        continue;
                    }

                    if (Cell.Column.Name == null)
                    {
                        continue;
                    }

                    if (Cell.Column.Name == "")
                    {
                        continue;
                    }

                    try
                    { Dr[Cell.Column.DataField] = Cell.Value; }
                    catch
                    { Dr[Cell.Column.DataField] = DBNull.Value; }
                }
            }

            if (HasDelete)
            {
                foreach (Int64 Key in List_DeletedKeys)
                {
                    DataRow[] ArrDr = Dt.Select(KeyField + " = " + Key);
                    if (ArrDr.Length > 0)
                    {
                        ArrDr[0].Delete();
                    }
                }
            }
        }
        //[-]

        public static void AddSelected(
            DataTable Dt_Target
            , DataTable Dt_Selected
            , string Query_Selected_Source
            , string Query_Selected_Key
            , string Target_Key
            , List <Str_AddSelectedFields> Obj_Fields = null
            , List <Str_AddSelectedFieldsDefault> Obj_FieldsDefault = null)
        {
            if (!(Dt_Selected.Rows.Count > 0))
            {
                return;
            }

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

            Pq.pQuery = @"Select * From " + Query_Selected_Source + @" Where " + Query_Selected_Key + @" = @ID";
            Pq.Add_Parameter("ID", Do_Constants.eParameterType.Long);
            Pq.Prepare();

            foreach (DataRow Dr_Selected in Dt_Selected.Rows)
            {
                //Pq.pParameters["ID"].Value = (Int64)Do_Methods.IsNull(Dr_Selected["ID"], 0);
                Pq.pParameter_Set("ID", Do_Methods.Convert_Int64(Dr_Selected["ID"]));
                DataTable Inner_Dt_Selected = Pq.ExecuteQuery().Tables[0];
                if (Inner_Dt_Selected.Rows.Count > 0)
                {
                    DataRow   Inner_Dr_Selected = Inner_Dt_Selected.Rows[0];
                    DataRow[] Inner_ArrDr;
                    DataRow   Inner_Dr_Target = null;
                    bool      Inner_IsFound   = false;

                    Inner_ArrDr = Dt_Target.Select(Target_Key + " = " + Convert.ToInt64(Inner_Dr_Selected[Query_Selected_Key]));
                    if (Inner_ArrDr.Length > 0)
                    {
                        Inner_Dr_Target = Inner_ArrDr[0];
                        if ((bool)Do_Methods.IsNull(Inner_Dr_Target["IsDeleted"], false))
                        {
                            Inner_Dr_Target["IsDeleted"] = DBNull.Value;
                            Inner_IsFound = true;
                        }
                    }

                    if (!Inner_IsFound)
                    {
                        Int64 Ct = 0;
                        Inner_ArrDr = Dt_Target.Select("", "TmpKey Desc");
                        if (Inner_ArrDr.Length > 0)
                        {
                            Ct = (Int64)Inner_ArrDr[0]["TmpKey"];
                        }
                        Ct++;

                        DataRow Nr = Dt_Target.NewRow();
                        Nr["TmpKey"]     = Ct;
                        Nr["Item_Style"] = "";
                        Nr[Target_Key]   = (Int64)Inner_Dr_Selected[Query_Selected_Key];
                        Dt_Target.Rows.Add(Nr);

                        Inner_Dr_Target = Nr;
                    }

                    if (Obj_Fields != null)
                    {
                        foreach (Str_AddSelectedFields Inner_Obj in Obj_Fields)
                        {
                            Inner_Dr_Target[Inner_Obj.Field_Target] = Inner_Dr_Selected[Inner_Obj.Field_Selected];
                        }
                    }

                    if (Obj_FieldsDefault != null)
                    {
                        foreach (Str_AddSelectedFieldsDefault Inner_Obj in Obj_FieldsDefault)
                        {
                            Inner_Dr_Target[Inner_Obj.Field_Target] = Inner_Obj.Value;
                        }
                    }
                }
            }
        }
        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);
        }
        void SetupPage()
        {
            this.SetupPage_ControlAttributes();
            this.SetupPage_Lookups();

            //[-]

            this.Txt_ItemCode.Text = Do_Methods.Convert_String(this.mObj.pDr_RowProperty["Code"]);
            this.Txt_ItemName.Text = Do_Methods.Convert_String(this.mObj.pDr_RowProperty["Name"]);
            this.Txt_Remarks.Text  = Do_Methods.Convert_String(this.mObj.pDr_RowProperty["Remarks"]);
            this.Txt_Warranty.Text = Do_Methods.Convert_String(this.mObj.pDr["Warranty"]);

            this.Chk_IsSerial.Checked = Do_Methods.Convert_Boolean(this.mObj.pDr["IsSerial"]);

            this.Txt_Length.Text = Do_Methods.Convert_Double(this.mObj.pDr["Size_Length"]).ToString("#,##0.0000");
            this.Txt_Width.Text  = Do_Methods.Convert_Double(this.mObj.pDr["Size_Width"]).ToString("#,##0.0000");
            this.Txt_Height.Text = Do_Methods.Convert_Double(this.mObj.pDr["Size_Height"]).ToString("#,##0.0000");
            this.Txt_Weight.Text = Do_Methods.Convert_Double(this.mObj.pDr["Size_Weight"]).ToString("#,##0.0000");

            this.Txt_FloorLevel.Text   = Do_Methods.Convert_Int64(this.mObj.pDr["Inv_FloorLevel"]).ToString("#,##0");
            this.Txt_CeilingLevel.Text = Do_Methods.Convert_Int64(this.mObj.pDr["Inv_CeilingLevel"]).ToString("#,##0");
            this.Txt_ReorderLevel.Text = Do_Methods.Convert_Int64(this.mObj.pDr["Inv_ReorderLevel"]).ToString("#,##0");

            this.Txt_EstimatedCost.Text = Do_Methods.Convert_Double(this.mObj.pDr["Cost"]).ToString("#,##0.00");
            this.Txt_ListPrice.Text     = Do_Methods.Convert_Double(this.mObj.pDr["Price"], 0).ToString("#,##0.00");

            bool IsImageFile = false;

            if ((string)Do_Methods.IsNull(this.mObj.pDr["Image_Path"], "") != "")
            {
                IsImageFile = true;
                System.IO.FileInfo Fi_Thumb =
                    new System.IO.FileInfo(
                        this.MapPath(Layer01_Constants_Web.CnsImageThumbPath
                                     + "Thumb_"
                                     + (string)Do_Methods.IsNull(this.mObj.pDr["Image_Path"], "")));
                if (!Fi_Thumb.Exists)
                {
                    try
                    {
                        Layer01_Methods_Web.ImageThumbnail(
                            this.MapPath(Layer01_Constants_Web.CnsImageThumbPath
                                         + (string)Do_Methods.IsNull(this.mObj.pDr["Image_Path"], ""))
                            , Fi_Thumb.FullName);
                    }
                    catch
                    { IsImageFile = false; }
                }

                this.Img_Box.ImageUrl      = Layer01_Constants_Web.CnsImageThumbPath + "Thumb_" + (string)Do_Methods.IsNull(this.mObj.pDr["Image_Path"], "");
                this.Btn_ViewImage.Visible = true;
            }

            if (!IsImageFile)
            {
                this.Img_Box.ImageUrl      = "~/System/Images/QuestionMark001.jpg";
                this.Btn_ViewImage.Visible = false;
            }

            if ((string)Do_Methods.IsNull(this.mObj.pDr["PdfDesc_Path"], "") == "")
            {
                this.Btn_PdfDesc.CssClass = Layer01_Constants_Web.CnsCssControlEnabledFalse;
                this.Btn_PdfDesc.Enabled  = false;
            }
            else
            {
                this.Btn_PdfDesc.CssClass = Layer01_Constants_Web.CnsCssControlEnabled;
                this.Btn_PdfDesc.Enabled  = true;
            }

            if ((string)Do_Methods.IsNull(this.mObj.pDr["PdfFaq_Path"], "") == "")
            {
                this.Btn_PdfFaq.CssClass = Layer01_Constants_Web.CnsCssControlEnabledFalse;
                this.Btn_PdfFaq.Enabled  = false;
            }
            else
            {
                this.Btn_PdfFaq.CssClass = Layer01_Constants_Web.CnsCssControlEnabled;
                this.Btn_PdfFaq.Enabled  = true;
            }

            if ((string)Do_Methods.IsNull(this.mObj.pDr["PdfOthers_Path"], "") == "")
            {
                this.Btn_PdfOther.CssClass = Layer01_Constants_Web.CnsCssControlEnabledFalse;
                this.Btn_PdfOther.Enabled  = false;
            }
            else
            {
                this.Btn_PdfOther.CssClass = Layer01_Constants_Web.CnsCssControlEnabled;
                this.Btn_PdfOther.Enabled  = true;
            }

            DataTable Dt_Defaults = Do_Methods_Query.GetQuery("uvw_Lookup");

            this.Cbo_Category.SelectedValue = ((Int64)Do_Methods.IsNull(this.mObj.pDr["LookupID_Category"], this.SetupPage_GetLookupDefault(Dt_Defaults, Layer01_Constants.eLookup.Category))).ToString();
            this.Cbo_ItemType.SelectedValue = ((Int64)Do_Methods.IsNull(this.mObj.pDr["LookupID_ItemType"], this.SetupPage_GetLookupDefault(Dt_Defaults, Layer01_Constants.eLookup.ItemType))).ToString();
            this.Cbo_Brand.SelectedValue    = ((Int64)Do_Methods.IsNull(this.mObj.pDr["LookupID_Brand"], this.SetupPage_GetLookupDefault(Dt_Defaults, Layer01_Constants.eLookup.Brand))).ToString();
            this.Cbo_Retailer.SelectedValue = ((Int64)Do_Methods.IsNull(this.mObj.pDr["LookupID_Category"], this.SetupPage_GetLookupDefault(Dt_Defaults, Layer01_Constants.eLookup.Retailer))).ToString();
            this.Cbo_ItemUOM.SelectedValue  = ((Int64)Do_Methods.IsNull(this.mObj.pDr["LookupID_ItemUOM"], this.SetupPage_GetLookupDefault(Dt_Defaults, Layer01_Constants.eLookup.UOM))).ToString();

            //[-]

            this.UcGrid_ItemPart.Setup(
                "Item_Part"
                , this.mObj.pDt_Part
                , "TmpKey"
                , false
                , true
                , this.mMaster.pIsReadOnly);
            this.UcGrid_ItemPart.pGrid.FullRowMode = false;

            this.UcGrid_ItemLocation.Setup(
                "Item_Location"
                , this.mObj.pDt_Location
                , "TmpKey"
                , false
                , true
                , this.mMaster.pIsReadOnly);
            this.UcGrid_ItemLocation.pGrid.FullRowMode = false;

            this.UcGrid_ItemSupplier.Setup(
                "Item_Supplier"
                , this.mObj.pDt_Supplier
                , "TmpKey"
                , false
                , true
                , this.mMaster.pIsReadOnly);
            this.UcGrid_ItemSupplier.pGrid.FullRowMode = false;

            DataTable Dt = Do_Methods_Query.GetQuery(
                "uvw_Materialized_InventoryWarehouse_Current_Item"
                , ""
                , "ItemID = " + Convert.ToInt64(Do_Methods.IsNull(this.mObj.pDr["ItemID"], 0)).ToString()
                , "WarehouseCodeName");

            this.mObj.AddRequired(Dt);
            this.UcGrid_OnHand.Setup("Item_Inventory", Dt);
            this.UcGrid_OnHand.pGrid.FullRowMode = false;
        }