//New
        protected void B_21_OnClick(object sender, EventArgs e)
        {
            try
            {
                Rep_General general = new Rep_General();
                DataTable   user    = (DataTable)Session["user"];

                int userId = int.Parse(user.Rows[0]["UserID"].ToString());

                string module = general.SelectModule(userId, "AccountSearch");
                if (module != "Stop")
                {
                    string accId = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                    Response.Redirect("~/Modules/" + module + ".aspx?" + general.ObfuscateQueryString("accID") + "=" + accId + "", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", "Access Denied"), true);
                }
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += error;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        private DataTable SelectContacts()
        {
            DataTable contactsDt = new DataTable();

            try
            {
                Rep_Account accountSearch = new Rep_Account();
                Rep_General general       = new Rep_General();

                DataTable User   = (DataTable)Session["user"];
                string    userId = User.Rows[0]["UserID"].ToString();
                string    accId  = "";

                if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                {
                    string value = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                    accId = general.DecryptIds(int.Parse(value)).ToString();
                }

                contactsDt = accountSearch.SelectContactSearch(int.Parse(userId), accId);
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "Error occurred please try again ";
                AlertMSG += errText;
                this.ClientScript.RegisterStartupScript(this.GetType(), this.GetType().Name,
                                                        string.Format("window.alert('{0}');", AlertMSG), true);
            }

            return(contactsDt);
        }
        protected void CustomersGRD_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "EditCommand")
            {
                //string strKey = e.CommandArgument.ToString();
                string strr = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AccID"].ToString();
                //Response.Redirect("~/Modules/Account/AccountAdd.aspx?ARXDWB=" + strr + "");

                try
                {
                    Rep_General accountSearch = new Rep_General();
                    DataTable   user          = (DataTable)Session["user"];

                    int userId = int.Parse(user.Rows[0]["UserID"].ToString());

                    string module = accountSearch.SelectModule(userId, "AccountAdd");
                    if (module != "Stop")
                    {
                        int accId = accountSearch.EncryptIds(int.Parse(strr));
                        Response.Redirect("~/Modules/" + module + ".aspx?" + accountSearch.ObfuscateQueryString("accID") + "=" + accId + "");
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", "Access Denied"), true);
                    }
                }
                catch (Exception ex)
                {
                    string error   = ex.Message;
                    string errText = error.Replace("\'", "");

                    string AlertMSG = "";
                    AlertMSG += error;
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
                }
            }

            #region Link
            else if (e.CommandName == "LinkCommand")
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("ShowconfirmDialog();"), true);
                lblAccId.Text = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AccID"].ToString();
            }
            #endregion Link

            #region Refresh Grid
            else if (e.CommandName == "RebindGrid")
            {
                SearchBTN_Click(null, null);
            }
            #endregion Refresh Grid


            #region Else
            else
            {
                SearchBTN_Click(null, null);
            }
            #endregion Else
        }
        protected void AddCustomerBTN_Click(object sender, EventArgs e)
        {
            //WindowsFlag = true;
            //AddCustomerWindow.Visible = true;
            //AddCustomerWindow.VisibleOnPageLoad = true;
            //Response.Redirect("CreateAccount.aspx");

            //Response.Redirect("~/Modules/Account/AccountCreate.aspx");
            //Response.Redirect("~/Modules/Account/AccountCreate.aspx?UZQF=1");

            try
            {
                Rep_General accountSearch = new Rep_General();
                DataTable   user          = (DataTable)Session["user"];

                int userId = int.Parse(user.Rows[0]["UserID"].ToString());

                string module = accountSearch.SelectModule(userId, "AccountAdd");
                if (module != "Stop")
                {
                    if (Request.QueryString[accountSearch.ObfuscateQueryString("accID")] != null)
                    {
                        string accId = Request.QueryString[accountSearch.ObfuscateQueryString("accID")].ToString();
                        Response.Redirect("~/Modules/" + module + ".aspx?" + accountSearch.ObfuscateQueryString("accID") + "=" + accId + "&" + accountSearch.ObfuscateQueryString("view") + "=1", false);
                    }
                    else
                    {
                        Response.Redirect("~/Modules/" + module + ".aspx", false);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", "Access Denied"), true);
                }
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += error;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        private void Select_Account_Crdt()
        {
            try
            {
                DataTable   User    = (DataTable)Session["user"];
                Rep_General general = new Rep_General();

                string      userId      = User.Rows[0]["UserID"].ToString();
                string      accId       = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                int         id          = general.DecryptIds(int.Parse(accId));
                Rep_Account accountCrdt = new Rep_Account();

                DataTable accCrdtTable = accountCrdt.SelectCrdt(int.Parse(userId), id);

                if (accCrdtTable.Rows.Count > 0)
                {
                    txtCrdtNo.Text      = accCrdtTable.Rows[0]["AccCrdtNo"].ToString();
                    dllCategory_1.Text  = accCrdtTable.Rows[0]["AccCrdtGategory1"].ToString();
                    dllCategory_2.Text  = accCrdtTable.Rows[0]["AccCrdtGategory2"].ToString();
                    dllResponsible.Text = accCrdtTable.Rows[0]["AccCrdtResp"].ToString();
                    dllType.Text        = accCrdtTable.Rows[0]["AccCrdtType"].ToString();
                    txtMax.Text         = accCrdtTable.Rows[0]["AccCrdtMax"].ToString();
                    txtExtra.Text       = accCrdtTable.Rows[0]["AccCrdtExtra"].ToString();
                    txtMemo.InnerText   = accCrdtTable.Rows[0]["AccCrdtMemo"].ToString();
                    RBLBlocked.Text     = accCrdtTable.Rows[0]["AccCrdtStop"].ToString() == "True" ? "1" : "2";
                    //RBLBlocked.Items.FindByText(accCrdTable.Rows[0]["AccCrdtStop"].ToString()).Selected = true;
                }
                else
                {
                }

                string texttaccNo = Request.QueryString[general.ObfuscateQueryString("accNo")] != null ? Request.QueryString[general.ObfuscateQueryString("accNo")].ToString() : "";
                accNo.Text = texttaccNo != string.Empty ? general.DecryptIds(int.Parse(texttaccNo)).ToString() : "";
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += errText;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        private void Select_Account_Name()
        {
            try
            {
                Rep_General general = new Rep_General();
                DataTable   User    = (DataTable)Session["user"];

                string userId = User.Rows[0]["UserID"].ToString();
                string accId  = "";
                if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                {
                    string value = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                    accId = general.DecryptIds(int.Parse(value)).ToString();
                }
                else
                {
                    //accId = lblAccID.Text;
                }


                Rep_Account account = new Rep_Account();

                DataTable accTable = account.SelectAcc(int.Parse(userId), int.Parse(accId));

                if (accTable.Rows.Count > 0)
                {
                    accNo.Text   = accTable.Rows[0]["AccNo"].ToString();
                    accName.Text = accTable.Rows[0]["AccName"].ToString();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += errText;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        protected void btnLinkContact_OnClick(object sender, EventArgs e)
        {
            try
            {
                Rep_General general     = new Rep_General();
                Rep_Account contactLink = new Rep_Account();
                DataTable   user        = (DataTable)Session["user"];

                int userId = int.Parse(user.Rows[0]["UserID"].ToString());
                int accId  = general.DecryptIds(int.Parse(Request.QueryString[general.ObfuscateQueryString("accID")].ToString()));

                int  accContactId = int.Parse(lblAccId.Text);
                byte contactType  = byte.Parse(ddlContactType.Text);

                contactLink.Contact_Link(userId, accId, accContactId, contactType);

                //return to contact page
                string module = general.SelectModule(userId, "AccountContact");
                if (module != "Stop")
                {
                    int value = int.Parse(Request.QueryString[general.ObfuscateQueryString("accID")].ToString());
                    Response.Redirect("~/Modules/" + module + ".aspx?" + general.ObfuscateQueryString("accID") + "=" + value + "", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", "Access Denied"), true);
                }
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += errText;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Generate_Buttons();
            Get_Navegation_Panel();
            Rep_General general = new Rep_General();

            if (!IsPostBack)
            {
                Get_ddls();
                Get_AccCrdt_Blocked();
            }

            if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
            {
                if (!IsPostBack)
                {
                    string lblaccId = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                    lblAccID.Text = general.DecryptIds(int.Parse(lblaccId)).ToString();
                    Select_Account_Crdt();
                    Select_Account_Name();
                    hidnViewFlag.Value = "View";
                    lblSubject.Text    = "View";
                }
            }
            else if (hidnViewFlag.Value == "Update")
            {
            }
            else
            {
                if (!IsPostBack)
                {
                    hidnViewFlag.Value = "Add";
                    lblSubject.Text    = "New";
                }
            }
            //get Roles after check the flag value
            Btn_Fields_Roles();
        }
        private void Get_ContactType()
        {
            try
            {
                Rep_General general     = new Rep_General();
                Rep_Account accountUdt  = new Rep_Account();
                DataTable   User        = (DataTable)Session["user"];
                DataTable   accUdtTable = new DataTable();

                string userId = User.Rows[0]["UserID"].ToString();
                string accId  = "";
                if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                {
                    string value = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                    accId       = general.DecryptIds(int.Parse(value)).ToString();
                    accUdtTable = accountUdt.SelectAcc(int.Parse(userId), int.Parse(accId));
                }
                else
                {
                }

                ddlContactType.DataSource     = SelectddlDataTable("SP_SysCode_AccContact_Type", accUdtTable.Rows[0]["AccCategory"].ToString());
                ddlContactType.DataTextField  = "ContactType";
                ddlContactType.DataValueField = "ContactTypeID";
                ddlContactType.DataBind();
                ddlContactType.Items.Insert(0, new ListItem("Select", "-1"));
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += errText;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        protected void panel_lnkAccSales_OnClick(object sender, EventArgs e)
        {
            Rep_General general = new Rep_General();

            foreach (GridDataItem selectinganItem in CustomersGRD.MasterTableView.Items)
            {
                if (selectinganItem.Selected)
                {
                    try
                    {
                        int accId = general.EncryptIds(int.Parse(selectinganItem["AccID"].Text));
                        int accNo = general.EncryptIds(int.Parse(selectinganItem["AccNo"].Text));

                        Rep_General accountSearch = new Rep_General();
                        DataTable   user          = (DataTable)Session["user"];

                        int userId = int.Parse(user.Rows[0]["UserID"].ToString());

                        string module = accountSearch.SelectModule(userId, "AccountSales");
                        if (module != "Stop")
                        {
                            Response.Redirect("~/Modules/" + module + ".aspx?" + general.ObfuscateQueryString("accID") + "=" + accId + "&" + general.ObfuscateQueryString("accNo") + "=" + accNo + "", false);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", "Access Denied"), true);
                        }
                    }
                    catch (Exception ex)
                    {
                        string error   = ex.Message;
                        string errText = error.Replace("\'", "");

                        string AlertMSG = "";
                        AlertMSG += error;
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", "Please select your record"), true);
                }
            }
        }
        private void Udt_Account_Crdt()
        {
            try
            {
                Rep_General general     = new Rep_General();
                Rep_Account accountCrdt = new Rep_Account();
                string      value       = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                DataTable   user        = (DataTable)Session["user"];

                int    userId        = int.Parse(user.Rows[0]["UserID"].ToString());
                int    accId         = general.DecryptIds(int.Parse(value));
                int    crdtNo        = int.Parse(txtCrdtNo.Text);
                byte   crdtCategory1 = byte.Parse(dllCategory_1.Text);
                byte   crdtCategory2 = byte.Parse(dllCategory_2.Text);
                byte   crdtType      = byte.Parse(dllType.Text);
                double crdtMax       = double.Parse(txtMax.Text);
                double crdtExtra     = double.Parse(txtExtra.Text);
                byte   crdtStop      = byte.Parse(RBLBlocked.Text);
                byte   crdtResp      = byte.Parse(dllResponsible.Text);
                string crdtMemo      = txtMemo.InnerText;

                string aUpdateCrdtccUdt = accountCrdt.UpdateCrdt(userId, accId, crdtNo, crdtCategory1, crdtCategory2, crdtType, crdtMax, crdtExtra, crdtStop, crdtResp, crdtMemo);

                Disable_Fields();
                Select_Account_Crdt();

                hidnViewFlag.Value = "View";
                lblSubject.Text    = "View";
                Btn_Fields_Roles();

                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", aUpdateCrdtccUdt), true);
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "";
                AlertMSG += error;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", AlertMSG), true);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Generate_Buttons();
            Get_Navegation_Panel();

            Rep_General general = new Rep_General();

            if (!IsPostBack)
            {
                if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                {
                    CustomersGRD.MasterTableView.Columns.FindByUniqueName("EditCustomer").Display = false;
                    Get_ContactType();
                    Select_Account_Name();
                    accHeader.Attributes["style"] = @"display: normal;";
                }
                else
                {
                    CustomersGRD.MasterTableView.Columns.FindByUniqueName("LinkCustomer").Display = false;
                }

                //DataTable InitialDT = SelectCustomers();
                //CustomersGRD.DataSource = InitialDT;
                //CustomersGRD.DataBind();

                //AddCustomerWindow.VisibleOnPageLoad = false;
            }
            else
            {
                //if (!WindowsFlag)
                //{
                //    AddCustomerWindow.VisibleOnPageLoad = false;
                //}
                //else
                //{
                //    AddCustomerWindow.VisibleOnPageLoad = true;
                //    WindowsFlag = false;
                //}
            }
        }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Get_Navegation_Panel();

            if (!IsPostBack)
            {
                Generate_Buttons();
                Rep_General general = new Rep_General();

                if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                {
                    if (hidnViewFlag.Value == "Update")
                    {
                        //hidnViewFlag.Value = "Update";
                        lblSubject.Text = "Edit";
                    }
                    else if (hidnViewFlag.Value == "Add")
                    {
                        //hidnViewFlag.Value = "Add";
                        lblSubject.Text = "New";
                    }

                    else
                    {
                        hidnViewFlag.Value = "View";
                        lblSubject.Text    = "View";



                        AccIDEnc.Value = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();

                        DataTable User = Session["user"] != null ? (DataTable)Session["user"] : new DataTable();
                        if (User.Rows.Count > 0)
                        {
                            UserID.Value   = User.Rows[0]["UserID"].ToString();
                            lblAccID.Text  = general.DecryptIds(int.Parse(AccIDEnc.Value)).ToString();
                            AccIDDec.Value = lblAccID.Text;



                            string texttaccNo = Request.QueryString[general.ObfuscateQueryString("accNo")] != null
                                ? Request.QueryString[general.ObfuscateQueryString("accNo")].ToString()
                                : "";
                            accNo.Text = texttaccNo != string.Empty ? general.DecryptIds(int.Parse(texttaccNo)).ToString() : "";

                            Rep_Account account = new Rep_Account();

                            DataTable accTable = account.SelectAcc(int.Parse(UserID.Value), int.Parse(AccIDDec.Value));

                            accName.Text = accTable.Rows.Count > 0 ? accTable.Rows[0]["AccName"].ToString() : string.Empty;


                            FillDDLs();

                            FillAccountSales(GetAccountSales());
                        }
                        else
                        {
                            B_11_OnClick(null, null);
                        }
                    }


                    //get Roles after check the flag value
                    Btn_Fields_Roles();
                    DisableEdit();
                }
                else
                {
                    B_11_OnClick(null, null);
                }
            }
            else
            {
                // FillAccountInfoGRD();
            }
        }
        private DataTable SelectCustomers()
        {
            //string SelectCommand = "SELECT  Account.AccID, Account.AccNo, Account.AccName, Account.Cancelled, AccountInfo.LineID, AccountInfo.InfoType, AccountInfo.InfoData, AccountInfo.Cancelled AS Expr1 "
            //                                             + " FROM Account INNER JOIN                                                                     "
            //                                             + " AccountInfo ON Account.AccID = AccountInfo.AccID                                            "
            //                                             + " and Account.Cancelled = 0                                                                   "
            //                                             + " and CONCAT(Account.AccNo ,' ' , Account.AccName ,' ', AccountInfo.InfoData) like @search       ";

            //SqlCommand SqlSelectCommand = new SqlCommand(SelectCommand, CustomersConnection);
            // SqlSelectCommand.Parameters.Add("@SearchText", SqlDbType.NVarChar, 65);
            //     SqlSelectCommand.Parameters.Add("@SearchText", System.Data.SqlDbType.Text);
            //     SqlSelectCommand.Parameters["@SearchText"].Value = SearchTXT.Text;

            //     adapter.InsertCommand.Parameters.Add("@CompanyName",
            //SqlDbType.VarChar, 40, "CompanyName");

            //SqlDataAdapter CustomersDA = new SqlDataAdapter("SP_Account_Search", CustomersConnection);
            //CustomersDA.SelectCommand.CommandType = CommandType.StoredProcedure;
            //CustomersDA.SelectCommand.Parameters.AddWithValue("@UserID", userId);
            //CustomersDA.SelectCommand.Parameters.AddWithValue("@SearchType", "Mobile");
            //CustomersDA.SelectCommand.Parameters.AddWithValue("@ModuleName", "AccountSearch");
            //CustomersDA.SelectCommand.Parameters.AddWithValue("@search", "%" + SearchTXT.Text + "%");
            //CustomersDA.SelectCommand.Parameters.AddWithValue("@SearchText", SearchTXT.Text);
            //Add(SearchTXT.Text);
            //CustomersDA.Fill(CustomersDT);

            DataTable CustomersDT = new DataTable();
            DataTable boundTable  = new DataTable();

            try
            {
                Rep_Account accountSearch = new Rep_Account();
                Rep_General general       = new Rep_General();

                DataTable User   = (DataTable)Session["user"];
                string    userId = User.Rows[0]["UserID"].ToString();

                CustomersDT = accountSearch.SelectSearch(int.Parse(userId), "Mobile", SearchTXT.Text, "AccountSearch");

                //if query string
                if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                {
                    DataTable contactsDt = new DataTable();
                    int       accId      = general.DecryptIds(int.Parse(Request.QueryString[general.ObfuscateQueryString("accID")].ToString()));
                    contactsDt = accountSearch.SelectContactSearch(int.Parse(userId), accId.ToString());

                    //var rows = from r in CustomersDT.AsEnumerable()
                    //    //make sure there aren't any matching names in dt2
                    //    where contactsDt.AsEnumerable().Any(r2 => r["AccID"].ToString() != r2["AccID"].ToString() && r["AccID"].ToString() != accId.ToString())
                    //    select r;

                    //var rows = CustomersDT.AsEnumerable().Where(r => contactsDt.AsEnumerable()
                    //    //make sure there aren't any matching names in dt2
                    //    .Any( r2 => r["AccID"].ToString() != r2["AccID"].ToString() ));

                    //boundTable = rows.CopyToDataTable();

                    if (CustomersDT.Rows.Count > 0)
                    {
                        boundTable = CustomersDT.Rows.OfType <DataRow>()
                                     .Where(a => CustomersDT.Rows.OfType <DataRow>().Select(k => Convert.ToInt32(k["AccID"])).Except(contactsDt.Rows.OfType <DataRow>()
                                                                                                                                     .Select(k => Convert.ToInt32(k["AccID"])).ToList()).Contains(Convert.ToInt32(a["AccID"])) && Convert.ToInt32(a["AccID"]) != accId).CopyToDataTable();
                    }
                }
                else
                {
                    if (CustomersDT.Rows.Count > 0)
                    {
                        boundTable = CustomersDT;
                    }
                }
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = "Error occurred please try again ";
                AlertMSG += errText;
                this.ClientScript.RegisterStartupScript(this.GetType(), this.GetType().Name,
                                                        string.Format("window.alert('{0}');", AlertMSG), true);
            }

            return(boundTable);
        }