Пример #1
0
    private void BindGrid()
    {
        string connection = Request.Cookies["Company"].Value;

        DataSet       ds = new DataSet();
        BusinessLogic bl = new BusinessLogic();

        object usernam = Session["LoggedUserName"];

        string txtSearch = string.Empty;

        ds = bl.ListUsers(txtSearch, connection);

        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                GrdViewCust.DataSource = ds.Tables[0].DefaultView;
                GrdViewCust.DataBind();
            }
        }
        else
        {
            GrdViewCust.DataSource = null;
            GrdViewCust.DataBind();
        }
    }
Пример #2
0
    private void FillUserGrid(DataView dvuserData)
    {
        GrdViewCust.DataSource = dvuserData;
        GrdViewCust.DataBind();

        if (dvuserData.Count == 0)
        {
            errordisplay1.AddItem("No customer found for the Search Criteria.", DisplayIcons.Information, false);
        }
    }
Пример #3
0
    protected void cmdSave_Click(object sender, EventArgs e)
    {
        try
        {
            DataSet   ds;
            DataTable dt;
            DataRow   drNew;

            DataColumn dc;

            ds = new DataSet();

            dt = new DataTable();

            dc = new DataColumn("UserName");
            dt.Columns.Add(dc);

            dc = new DataColumn("Role");
            dt.Columns.Add(dc);

            dc = new DataColumn("RoleDesc");
            dt.Columns.Add(dc);

            dc = new DataColumn("Section");
            dt.Columns.Add(dc);

            dc = new DataColumn("Area");
            dt.Columns.Add(dc);

            dc = new DataColumn("Orderno");
            dt.Columns.Add(dc);

            dc = new DataColumn("Add");
            dt.Columns.Add(dc);

            dc = new DataColumn("Edit");
            dt.Columns.Add(dc);

            dc = new DataColumn("Delete");
            dt.Columns.Add(dc);

            dc = new DataColumn("View");
            dt.Columns.Add(dc);

            ds.Tables.Add(dt);
            bool Add    = false;
            bool Edit   = false;
            bool Delete = false;

            bool  Views       = false;
            Label lblDebtorID = null;

            for (int vLoop = 0; vLoop < GrdViewItem.Rows.Count; vLoop++)
            {
                CheckBox txt = (CheckBox)GrdViewItem.Rows[vLoop].FindControl("chkboxAdd");
                if (txt.Checked)
                {
                    Add = txt.Checked;
                }
                else
                {
                    Add = false;
                }

                CheckBox txttt = (CheckBox)GrdViewItem.Rows[vLoop].FindControl("chkboxEdit");
                if (txttt.Checked)
                {
                    Edit = txttt.Checked;
                }
                else
                {
                    Edit = false;
                }

                CheckBox txth = (CheckBox)GrdViewItem.Rows[vLoop].FindControl("chkboxDel");
                if (txth.Checked)
                {
                    Delete = txth.Checked;
                }
                else
                {
                    Delete = false;
                }

                CheckBox txthh = (CheckBox)GrdViewItem.Rows[vLoop].FindControl("chkboxView");
                if (txthh.Checked)
                {
                    Views = txthh.Checked;
                }
                else
                {
                    Views = false;
                }

                drNew             = dt.NewRow();
                drNew["UserName"] = txtUser.Text;
                drNew["Role"]     = GrdViewItem.Rows[vLoop].Cells[3].Text;
                drNew["RoleDesc"] = GrdViewItem.Rows[vLoop].Cells[2].Text;
                drNew["Section"]  = GrdViewItem.Rows[vLoop].Cells[1].Text;
                drNew["Area"]     = GrdViewItem.Rows[vLoop].Cells[0].Text;

                lblDebtorID      = (Label)GrdViewItem.Rows[vLoop].FindControl("lblDebtorID");
                drNew["Orderno"] = lblDebtorID.Text;

                drNew["Add"]    = Add;
                drNew["Edit"]   = Edit;
                drNew["Delete"] = Delete;
                drNew["View"]   = Views;
                ds.Tables[0].Rows.Add(drNew);
            }

            string Userna = Request.Cookies["LoggedUserName"].Value;

            string userName   = string.Empty;
            string Email      = string.Empty;
            string connection = string.Empty;

            bool Locked   = chkAccLocked.Checked;
            bool DateLock = chkboxdatelock.Checked;

            if (txtUser.Text != string.Empty)
            {
                userName = txtUser.Text;
            }
            if (txtEmail.Text != string.Empty)
            {
                Email = txtEmail.Text;
            }
            if (Request.Cookies["Company"] != null)
            {
                connection = Request.Cookies["Company"].Value;
            }

            string  UserGroup = string.Empty;
            bool    DateLoc   = true;
            DataSet dsd       = new DataSet();
            DataSet dsbranch  = new DataSet();
            int     EmpNo     = 0;

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    BusinessLogic objBL = new BusinessLogic();

                    objBL = new BusinessLogic(ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ToString());

                    if (Session["Show"] == "Add New")
                    {
                        if (objBL.InsertUserOptions(ds, Userna, userName, Email, Locked, DateLock, dsd, "", EmpNo, UserGroup, DateLoc, dsbranch, false, "", false, ""))
                        {
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('User And their Options Saved Successfully');", true);
                            //BindGrid();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('User already exists. Please try again.');", true);
                            return;
                        }
                    }
                    else if (Session["Show"] == "Edit")
                    {
                        objBL.UpdateUserOptions(connection, ds, Userna, userName, Email, Locked, DateLock, dsd, "", EmpNo, UserGroup, DateLoc, dsbranch, false, "", false, "");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('User And their Options Updated Successfully');", true);
                        //BindGrid();
                    }
                }
                else
                {
                }
            }

            ModalPopupGet.Hide();
            GrdViewCust.DataBind();
            UpdatePanelPage.Update();
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }