コード例 #1
0
 protected void BtnClear_Click(object sender, EventArgs e)
 {
     lblActive.Visible          = false;
     DropDownListactive.Visible = false;
     PubDept.Visible            = false;
     RadioButtonListDeparmentPubincharge.Visible = false;
     RadioButtonListDeparmentPubincharge.Items.Clear();
     DDLrolename.Enabled  = true;
     txtuserid.Text       = "";
     txtuserid.Enabled    = true;
     TextBoxFname.Text    = "";
     TextBoxFname.Enabled = true;
     TextBoxMname.Text    = "";
     TextBoxMname.Enabled = true;
     TextBoxLName.Text    = "";
     TextBoxLName.Enabled = true;
     DropDownListPrefix.ClearSelection();
     DropDownListPrefix.Enabled = true;
     //  txtname.Text = "";
     //txtname.Enabled = true;
     //    DDLdeptname.Items.Clear();
     DDLdeptname.Items.Clear();
     DDLdeptname.Items.Add(new ListItem("--Select--", "0", true));
     DDLdeptname.DataBind();
     DDLdeptname.Enabled = true;
     txtemailid.Text     = "";
     txtemailid.Enabled  = true;
     DDLinstitutename.Items.Clear();
     DDLinstitutename.Items.Add(new ListItem("--Select--", "0", true));
     DDLinstitutename.DataBind();
     DDLinstitutename.Enabled = true;
     //RBLautoapproval.Enabled = true;
     //RBLautoapproval.SelectedValue = "Y";
     DDLrolename.Items.Clear();
     DDLrolename.Items.Add(new ListItem("--Select--", "0", true));
     DDLrolename.DataBind();
     GridViewUser.Visible = false;
     //  DDLrolename.SelectedValue = "";
     btnupdate.Enabled = false;
     btninsert.Enabled = true;
 }
コード例 #2
0
    protected void DeptcodeTextChanged(object sender, EventArgs e)
    {
        try
        {
            User_Mangement v  = new User_Mangement();
            User           b  = new User();
            User           b1 = new User();

            //b.UserId = null;
            //b.UserId = txtuserid.Text;
            b.User_Id = null;
            // b.User_Id = txtuserid.Text;

            b = v.selectExistingUser(txtuserid.Text.Trim());

            if (b.User_Id != null)
            {
                lblActive.Visible                = true;
                DropDownListactive.Visible       = true;
                txtuserid.Text                   = b.User_Id;
                DropDownListPrefix.SelectedValue = b.UserNamePrefix;
                DropDownListPrefix.Enabled       = false;
                TextBoxFname.Text                = b.UserFirstName;
                TextBoxFname.Enabled             = false;
                TextBoxMname.Text                = b.UserMiddleName;
                TextBoxMname.Enabled             = false;
                TextBoxLName.Text                = b.UserLastName;
                TextBoxLName.Enabled             = false;
                DDLinstitutename.SelectedValue   = b.Institute_name;
                DDLinstitutename.Enabled         = false;

                DropDownListactive.SelectedValue = b.Active;
                DropDownListactive.Enabled       = false;

                DDLdeptname.Items.Clear();

                SqlDataSource1.SelectParameters.Clear();
                SqlDataSource1.SelectParameters.Add("Institute_Id", DDLinstitutename.SelectedValue);

                // DDLdeptname.Items.Add(new ListItem("--Select--", "", true));
                SqlDataSource1.SelectCommand = "SELECT DISTINCT [DeptName], [DeptId] FROM [Dept_M] where Institute_Id =@Institute_Id";
                SqlDataSource1.DataBind();
                DDLdeptname.DataBind();

                DDLdeptname.SelectedValue = b.Department;
                DDLdeptname.DataBind();
                DDLdeptname.Enabled  = false;
                txtemailid.Text      = b.EmailId;
                Session["OldmailID"] = txtemailid.Text;
                if (txtemailid.Text == "" || txtemailid.Text == null)
                {
                    txtemailid.Enabled = true;
                }
                else
                {
                    txtemailid.Enabled = true;
                }
                //RBLautoapproval.Text = b.AutoApproved;
                //RBLautoapproval.Enabled = false;
                // SqlDataSource3.SelectCommand = "";
                if (b.Role_Id == 5)
                {//librarian
                    SqlDataSource3.SelectCommand = "SELECT DISTINCT [Role_Name], [Role_Id] FROM [Role_M] ";
                    SqlDataSource3.DataBind();
                    DDLrolename.DataBind();
                }
                else
                {
                    // SqlDataSource3.SelectCommand = "SELECT DISTINCT [Role_Name], [Role_Id] FROM [Role_M]  where Role_Id!=5";
                    // SqlDataSource3.DataBind();
                    //DDLrolename.DataBind();
                }
                DDLrolename.SelectedValue = Convert.ToString(b.Role_Id);
                if (b.Role_Id == 1)
                {
                    DDLrolename.Enabled = true;
                    btnupdate.Enabled   = true;
                    RadioButtonListDeparmentPubincharge.Items.Clear();
                    string deptname  = DDLdeptname.SelectedItem.ToString();
                    string deptvalue = DDLdeptname.SelectedValue;
                    PubDept.Visible = true;
                    RadioButtonListDeparmentPubincharge.Visible = true;
                    RadioButtonListDeparmentPubincharge.Items.Add(new ListItem(deptname, deptvalue, true));
                    RadioButtonListDeparmentPubincharge.Items.Add(new ListItem("All Departments of Institute", "", true));

                    b1 = v.selectPubInchargeUM(txtuserid.Text.Trim());

                    RadioButtonListDeparmentPubincharge.SelectedValue = b1.Department_Id;
                    RadioButtonListDeparmentPubincharge.DataBind();
                }
                else if (b.Role_Id == 5)
                {
                    //librarian
                    DDLrolename.Enabled = false;
                    btnupdate.Enabled   = false;
                }
                else
                {
                    DDLrolename.Enabled = true;
                    btnupdate.Enabled   = true;
                    PubDept.Visible     = false;
                    RadioButtonListDeparmentPubincharge.Visible = false;
                    RadioButtonListDeparmentPubincharge.Items.Clear();
                }
                txtuserid.Enabled = false;
                btninsert.Enabled = false;
                // btnupdate.Enabled = true;
                popupPanelBaCode.Visible = false;
                ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert(' User exixts!')</script>");
            }

            else
            {
                lblActive.Visible          = false;
                DropDownListactive.Visible = false;
                btninsert.Enabled          = true;
                btnupdate.Enabled          = false;
                txtuserid.Enabled          = false;
                popupPanelBaCode.Visible   = false;
                ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert(' New User!')</script>");
            }
        }

        catch (Exception ex)
        {
            log.Error(ex.StackTrace);
            log.Error(ex.Message);

            log.Error("Error!!!!!!!!!!!!!!!! ");
            if (ex.Message.Contains("DDLdeptname' has a SelectedValue which is invalid because it does not exist in the list of"))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!Institue_Department Map error!!!')</script>");
            }

            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>");
            }
        }
    }