protected void Page_Init(object sender, EventArgs e)
        {
            Rep_General general = new Rep_General();

            if (Request.QueryString[general.ObfuscateQueryString("accID")] == null)
            {
                //Response.Redirect("~/Modules/Account/AccountSearch.aspx");
                try
                {
                    DataTable user = (DataTable)Session["user"];

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

                    string module = general.SelectModule(userId, "AccountSearch");
                    if (module != "Stop")
                    {
                        Response.Redirect("~/Modules/" + module + ".aspx");
                    }
                    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);
                }
            }
        }
        //View
        protected void B_12_OnClick(object sender, EventArgs e)
        {
            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(lblAccID.Text));
                    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);
            }
        }
        private DataTable SelectddlDataTable(string proceduer, string param)
        {
            DataTable ddlTable = new DataTable();

            try
            {
                Rep_General accountCrdtDdlsDetails = new Rep_General();
                DataTable   User   = (DataTable)Session["user"];
                string      userId = User.Rows[0]["UserID"].ToString();

                ddlTable = accountCrdtDdlsDetails.SelectddlDataTable(int.Parse(userId), proceduer, param);
            }
            catch (Exception ex)
            {
                string Error    = ex.Message;
                string AlertMSG = "";
                AlertMSG += Error;
                this.ClientScript.RegisterStartupScript(this.GetType(), this.GetType().Name,
                                                        string.Format("window.alert('{0}');", AlertMSG), true);

                return(ddlTable);
            }

            return(ddlTable);
        }
示例#4
0
        private void Generate_Buttons()
        {
            try
            {
                Rep_General btnGeneral = new Rep_General();

                DataTable dtBtns = new DataTable();

                dtBtns = btnGeneral.BtnsDataTable();

                int i = 0;
                foreach (LinkButton lnkButton in btnsPanel.Controls.OfType <LinkButton>())
                {
                    for (i = i; i < dtBtns.Rows.Count;)
                    {
                        //lnkButton.ID = dtBtns.Rows[i]["ID"].ToString();
                        lnkButton.Text    = dtBtns.Rows[i]["Text"].ToString();
                        lnkButton.ToolTip = dtBtns.Rows[i]["Title"].ToString();
                        i++;
                        break;
                    }

                    //Add triggers to update panel if needed
                    //if (lnkButton.Enabled == true)
                    //{
                    //    if (lnkButton.ToolTip == "Export" || lnkButton.ToolTip == "Import")
                    //    {
                    //        //Button button = (Button)sender;
                    //        //string buttonId = button.ID;
                    //        //TriggerId = lnkButton.ID;
                    //        ScriptManager.GetCurrent(Page).RegisterPostBackControl(lnkButton);
                    //    }
                    //}
                }
            }

            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 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);
            }
        }
        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 Buttons_permissions()
        {
            try
            {
                Rep_General btnGeneral      = new Rep_General();
                DataTable   dtPermittedBtns = new DataTable();
                DataTable   User            = (DataTable)Session["user"];
                string      userId          = User.Rows[0]["UserID"].ToString();

                dtPermittedBtns = btnGeneral.Permitted_buttons(int.Parse(userId), "AccountCrdt");
                foreach (LinkButton lnkButton in btnsPanel.Controls.OfType <LinkButton>())
                {
                    //Add button permission
                    //you should give column name 'OptionID=' or it will give you this error "exception: filter expression does not evaluate to a boolean term"
                    string    find      = "OptionID=" + lnkButton.ID.ToString().Replace("B_", "");
                    DataRow[] foundRows = dtPermittedBtns.Select(find);

                    if (foundRows.Length != 0)
                    {
                        lnkButton.Enabled = true;
                    }
                    else
                    {
                        //these options we enable it or disable it as needed
                        if (find == "OptionID=18" || find == "OptionID=19" || find == "OptionID=29")
                        {
                        }
                        else
                        {
                            lnkButton.Enabled = false;
                        }
                    }
                }
            }
            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_lnkAccInfo_OnClick(object sender, EventArgs e)
        {
            Rep_General general = new Rep_General();

            if (accNo.Text != "")
            {
                try
                {
                    string value = "";
                    if (Request.QueryString[general.ObfuscateQueryString("accID")] != null)
                    {
                        value = Request.QueryString[general.ObfuscateQueryString("accID")].ToString();
                    }

                    int accId    = int.Parse(value);
                    int accNoTXT = general.EncryptIds(int.Parse(accNo.Text));


                    DataTable user = (DataTable)Session["user"];

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

                    string module = general.SelectModule(userId, "AccountInfo");
                    if (module != "Stop")
                    {
                        Response.Redirect("~/Modules/" + module + ".aspx?" + general.ObfuscateQueryString("accID") + "=" + accId + "&" + general.ObfuscateQueryString("accNo") + "=" + accNoTXT + "", 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 Get_Navegation_Panel()
        {
            try
            {
                Rep_General general      = new Rep_General();
                DataTable   navInfoTable = new DataTable();
                DataTable   user         = (DataTable)Session["user"];
                int         userId       = int.Parse(user.Rows[0]["UserID"].ToString());

                navInfoTable = general.NavegationDetails(userId, ModuleName);

                foreach (DataRow dataRow in navInfoTable.Rows)
                {
                    LinkButton linkButton = new LinkButton();

                    linkButton.ID               = "lB_" + dataRow["ModuleName"].ToString();
                    linkButton.CssClass         = "btn btn-default";
                    linkButton.Text             = dataRow["MenuName"].ToString();
                    linkButton.CausesValidation = false;
                    linkButton.CommandArgument  = dataRow["ModulePath"].ToString();
                    linkButton.CommandName      = dataRow["ModuleName"].ToString();
                    linkButton.Command         += new CommandEventHandler(DynamicCommand);

                    btn_Group_Panel.Controls.Add(linkButton);
                }

                LinkButton linkButtonClose = new LinkButton();
                linkButtonClose.Text        = "Close";
                linkButtonClose.CssClass    = "btn btn-default";
                linkButtonClose.PostBackUrl = "~/Modules/Home/Home.aspx";
                btn_Group_Panel.Controls.Add(linkButtonClose);
            }
            catch (Exception ex)
            {
                string error   = ex.Message;
                string errText = error.Replace("\'", "");

                string AlertMSG = " ";
                AlertMSG += errText;
                this.ClientScript.RegisterStartupScript(this.GetType(), this.GetType().Name,
                                                        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);
            }
        }
        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;
                //}
            }
        }
示例#14
0
        private void Change_Password()
        {
            try
            {
                Rep_General passwordSave = new Rep_General();
                DataTable   user         = (DataTable)Session["user"];
                string      passMsg      = "";

                int userId = int.Parse(user.Rows[0]["UserID"].ToString());
                //TextBox txtBusinessDate = (TextBox)Page.Master.FindControl("txtOldPassword");
                string oldPass = txtOldPassword.Text;
                string newPass = txtNewPassword.Text;

                if (correctFX1.Value != "1")
                {
                    if (txtNewPassword.Text != txtConfirmPassword.Text)
                    {
                        chngPasswordMsg.Text = "New password does not match the confirm password";
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Pop", string.Format("ClosepassModal();"), true);
                    }
                    else
                    {
                        passMsg = passwordSave.Password_Save(userId, oldPass, newPass);

                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Pop", string.Format("ClosepassModal();"), true);
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", string.Format("window.alert('{0}');", passMsg), 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);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Pop", string.Format("ClosepassModal();"), true);
            }
        }
        protected void ContactsGRD_OnItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "EditCommand")
            {
                //string strKey = e.CommandArgument.ToString();
                string strr = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AccID"].ToString();
                //string mainAccId = ContactsGRD.MasterTableView.Items[e.Item.ItemIndex]["MainAccID"].Text;
                //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);
                }
            }
        }
        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();
        }
        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);
            }
        }
        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);
            }
        }
示例#19
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 void Generate_Buttons()
        {
            try
            {
                Rep_General btnGeneral = new Rep_General();

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

                dtBtns          = btnGeneral.BtnsDataTable();
                dtPermittedBtns = btnGeneral.Permitted_buttons(int.Parse(userId), "AccountContact");

                int i = 0;
                foreach (LinkButton lnkButton in btnsPanel.Controls.OfType <LinkButton>())
                {
                    for (i = i; i < dtBtns.Rows.Count;)
                    {
                        //lnkButton.ID = dtBtns.Rows[i]["ID"].ToString();
                        lnkButton.Text    = dtBtns.Rows[i]["Text"].ToString();
                        lnkButton.ToolTip = dtBtns.Rows[i]["Title"].ToString();
                        i++;
                        break;
                    }

                    //Add button permission
                    //you should give column name 'OptionID=' or it will give you this error "exception: filter expression does not evaluate to a boolean term"
                    string    find      = "OptionID=" + lnkButton.ID.ToString().Replace("B_", "");
                    DataRow[] foundRows = dtPermittedBtns.Select(find);

                    if (foundRows.Length != 0)
                    {
                        lnkButton.Enabled = true;
                    }
                    else
                    {
                        //these options we enable it or disable it as needed
                        if (find == "OptionID=18" || find == "OptionID=19" || find == "OptionID=29")
                        {
                        }
                        else
                        {
                            lnkButton.Enabled = false;
                        }
                    }

                    //Add triggers to update panel if needed
                    //if (lnkButton.Enabled == true)
                    //{
                    //    if (lnkButton.ToolTip == "Export" || lnkButton.ToolTip == "Import")
                    //    {
                    //        //Button button = (Button)sender;
                    //        //string buttonId = button.ID;
                    //        //TriggerId = lnkButton.ID;
                    //        ScriptManager.GetCurrent(Page).RegisterPostBackControl(lnkButton);
                    //    }
                    //}
                }
            }

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