示例#1
0
    protected void GrdReport_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            switch (e.CommandName)
            {
            case ("Select"):
            {
                if (Convert.ToInt32(e.CommandArgument) != 0)
                {
                    ViewState["EditID"] = Convert.ToInt32(e.CommandArgument);
                    Ds = obj_DMUserMaster.GetUserDetailsForEdit(Convert.ToInt32(e.CommandArgument), out StrError);

                    if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
                    {
                        txtUser.Text     = Ds.Tables[0].Rows[0]["LoginName"].ToString();
                        TxtEmailid.Text  = Ds.Tables[0].Rows[0]["EmailId"].ToString();
                        TxtUserName.Text = Ds.Tables[0].Rows[0]["UserName"].ToString();
                        txtpassword.Attributes["value"]        = Ds.Tables[0].Rows[0]["Password"].ToString();
                        txtConfirmpassword.Attributes["value"] = Ds.Tables[0].Rows[0]["Password"].ToString();
                        //ddlEmployee.SelectedValue = Ds.Tables[0].Rows[0]["EmpID"].ToString();
                        string str;
                        str = Ds.Tables[0].Rows[0]["IsAdmin"].ToString();
                        if (str.Equals("True"))
                        {
                            RadioIsAdmin.Text    = "T";
                            PnlUserRight.Enabled = false;
                        }
                        else
                        {
                            RadioIsAdmin.Text    = "F";
                            PnlUserRight.Enabled = true;
                        }
                    }
                    if (Ds.Tables[1].Rows.Count > 0)
                    {
                        GridUserRight.DataSource = Ds.Tables[1];
                        GridUserRight.DataBind();
                        DisableCheckbox();
                    }
                    else
                    {
                        MakeEmptyform();
                    }
                    if (Ds.Tables[2].Rows.Count > 0)
                    {
                        //ChkProject.DataSource = Ds.Tables[2];
                        //ChkProject.DataValueField = "PCId";
                        //ChkProject.DataTextField = "Project";
                        //ChkProject.DataBind();
                        ViewState["IsCentral"] = Ds.Tables[2];

                        //for (int i = 0; i < ChkProject.Items.Count; i++)
                        //{
                        //    if (Convert.ToBoolean(Ds.Tables[2].Rows[i]["Cheked"]) == false)
                        //    {
                        //        ChkProject.Items[i].Selected = false;
                        //    }
                        //    else
                        //    {
                        //        ChkProject.Items[i].Selected = true;
                        //    }
                        //}
                    }
                    Ds = null;
                    obj_DMUserMaster = null;

                    if (!FlagEdit)
                    {
                        BtnUpdate.Visible = true;
                    }
                    if (!FlagDel)
                    {
                        BtnDelete.Visible = true;
                    }
                    BtnSave.Visible = false;
                    //TxtUserName.Focus();
                }
            }
            break;
            }
        }
        catch (Exception ex)
        {
            StrError = ex.Message;
        }
    }
    protected void GrdReport_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        flag = 1;
        try
        {
            switch (e.CommandName)
            {
            case ("Select"):
            {
                if (Convert.ToInt32(e.CommandArgument) != 0)
                {
                    ViewState["EditID"] = Convert.ToInt32(e.CommandArgument);
                    DS = Obj_UserMaster.GetUserDetailsForEdit(Convert.ToInt32(e.CommandArgument), out StrError);
                    DataTable dt = new DataTable();
                    //  dt = (DataTable)ViewState["IsCentral"];
                    if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0)
                    {
                        TxtUserId.Text   = DS.Tables[0].Rows[0]["LoginName"].ToString();
                        TxtMailId.Text   = DS.Tables[0].Rows[0]["EmailId"].ToString();
                        TxtUserName.Text = DS.Tables[0].Rows[0]["UserName"].ToString();
                        TxtPasswrod.Attributes["value"]      = DS.Tables[0].Rows[0]["Password"].ToString();
                        TxtConfrmPasswrd.Attributes["value"] = DS.Tables[0].Rows[0]["Password"].ToString();

                        string str;
                        str = DS.Tables[0].Rows[0]["IsAdmin"].ToString();
                        if (str.Equals("True"))
                        {
                            RadioIsAdmin.Text = "T";
                        }
                        else
                        {
                            RadioIsAdmin.Text = "F";
                        }
                    }
                    if (DS.Tables[1].Rows.Count > 0)
                    {
                        GridUserRight.DataSource = DS.Tables[1];
                        GridUserRight.DataBind();
                    }
                    if (DS.Tables[2].Rows.Count > 0)
                    {
                        GridUser.DataSource = DS.Tables[2];
                        GridUser.DataBind();
                    }
                    if (DS.Tables[3].Rows.Count > 0)
                    {
                        ChkSite.DataSource     = DS.Tables[3];
                        ChkSite.DataValueField = "CafeteriaId";
                        ChkSite.DataTextField  = "Cafeteria";
                        ChkSite.DataBind();
                        ViewState["IsCentral"] = DS.Tables[3];

                        for (int i = 0; i < ChkSite.Items.Count; i++)
                        {
                            if (Convert.ToBoolean(DS.Tables[3].Rows[i]["Cheked"]) == false)
                            {
                                ChkSite.Items[i].Selected = false;
                            }
                            else
                            {
                                ChkSite.Items[i].Selected = true;
                            }
                        }
                    }
                    else
                    {
                        FillGrid();
                        //MakeEmptyForm();
                    }
                    if (DS.Tables[4].Rows.Count > 0)
                    {
                        for (int k = 0; k < DS.Tables[4].Rows.Count; k++)
                        {
                            if (DS.Tables[4].Rows[k]["Form"].ToString() == "Edit Authorised Purchase Order")
                            {
                                CHKYESEDITPO.Checked = true;
                                TXTPASSEDITPO.Text   = DS.Tables[4].Rows[k]["Password"].ToString();
                            }
                            if (DS.Tables[4].Rows[k]["Form"].ToString() == "Unit Conversion In Item Master")
                            {
                                CHKYESUNITCONVERSION.Checked = true;
                            }
                            if (DS.Tables[4].Rows[k]["Form"].ToString() == "Purchase Order Shortage/Excess Report")
                            {
                                CHKESCESSREPORT.Checked = true;
                                TXTEXCESSREPORT.Text    = DS.Tables[4].Rows[k]["Password"].ToString();
                            }
                        }
                    }
                    else
                    {
                        CHKESCESSREPORT.Checked = CHKYESUNITCONVERSION.Checked = CHKYESEDITPO.Checked = false;
                        TXTEXCESSREPORT.Text    = TXTPASSEDITPO.Text = "";
                    }
                    DS              = null;
                    Obj_UserMaster  = null;
                    BtnSave.Visible = false;
                    if (!FlagEdit)
                    {
                        BtnUpdate.Visible = true;
                    }
                    if (!FlagDel)
                    {
                        BtnDelete.Visible = true;
                    }
                    TxtUserName.Focus();
                }
            }
            break;
            }
        }

        catch (Exception ex)
        {
            StrError = ex.Message;
        }
    }