Example #1
0
    protected void btnupdate_Click(object sender, EventArgs e) //update button
    {
        try
        {
            User_Mangement bl = new User_Mangement();
            Business       B  = new Business();
            b.User_Id       = txtuserid.Text.Trim();
            b.Name          = TextBoxName.Text.Trim();
            b.Department_Id = DDLdeptname.SelectedValue;
            b.EmailId       = txtemailid.Text.Trim();
            b.InstituteId   = DDLinstitutename.SelectedValue;
            if (txtDOB.Text != "01/01/0001" && txtDOB.Text != null && txtDOB.Text != "")
            {
                b.StudentDOB = Convert.ToDateTime(txtDOB.Text.Trim());
            }
            if (txtMobileNo.Text != "")
            {
                b.MobileNo = txtMobileNo.Text;
            }
            b.Sex = DropDownListsex.SelectedValue;
            //b.BankAccountNumber = txtaccno.Text;
            b.CreatedDate = DateTime.Now.ToString("yyyy-MM-dd");
            b.UpdatedBy   = Session["UserId"].ToString();
            string OldmailID      = Session["OldmailID"].ToString();
            int    isupdatemailid = 0;
            if (OldmailID != "")
            {
                if (OldmailID != b.emailId)
                {
                    isupdatemailid = 1;
                }
            }
            //if (b.Role_Id == 1)
            //{
            //    b.pubinchargedept = RadioButtonListDeparmentPubincharge.SelectedValue;
            //}
            // int retemail = bl.Updatestudentmailid(txtemailid.Text, b, isupdatemailid, OldmailID);
            //   b.Role_Name = DDLrolename.SelectedValue;
            int retVal = bl.UpdateStudentdetails(b); //Business layer
            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('User detail update successfully')</script>");
            //btninsert.Enabled = false;
            txtemailid.Enabled       = false;
            popupPanelBaCode.Visible = false;
            GridViewUser.DataBind();
            GridViewUser.Visible = false;
        }
        catch (Exception ex)
        {
            log.Error(ex.StackTrace);
            log.Error(ex.Message);

            log.Error("Error!!!!!!!!!!!!!!!! ");

            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>");
        }
    }
Example #2
0
    protected void btn_insert(object sender, EventArgs e) //insert button
    {
        if (!Page.IsValid)
        {
            return;
        }

        try
        {
            b.User_Id = txtuserid.Text.Trim();
            // b.Name = txtname.Text;
            b.UserNamePrefix = DropDownListPrefix.SelectedValue;
            b.UserFirstName  = TextBoxFname.Text.Trim();
            b.UserMiddleName = TextBoxMname.Text.Trim();
            b.UserLastName   = TextBoxLName.Text.Trim();
            b.Department_Id  = DDLdeptname.SelectedValue;
            b.EmailId        = txtemailid.Text.Trim();
            b.InstituteId    = DDLinstitutename.SelectedValue;
            b.AutoApproved   = "Y";
            b.Role_Id        = Convert.ToInt32(DDLrolename.SelectedValue);
            b.CreatedDate    = DateTime.Now.ToString("yyyy-MM-dd");
            b.CreatedBy      = Session["UserId"].ToString();
            if (b.Role_Id == 1)
            {
                b.pubinchargedept = RadioButtonListDeparmentPubincharge.SelectedValue;
            }

            int retVal = bl.SaveDepartmentDetails(b);

            //lblStatus.Text = "";
            lblStatus.ForeColor = System.Drawing.Color.Green;
            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('User detail saved successfully');window.location='" + Request.ApplicationPath + "/UserManagement/User_manager.aspx';</script>");

            GridViewUser.Visible     = false;
            btninsert.Enabled        = false;
            btninsert.Enabled        = true;
            popupPanelBaCode.Visible = false;
            b  = null;
            bl = null;
        }
        catch (Exception ex)
        {
            log.Error(ex.StackTrace);
            log.Error(ex.Message);

            log.Error("Error!!!!!!!!!!!!!!!! ");

            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>");
        }
    }
Example #3
0
    protected void btn_insert(object sender, EventArgs e) //insert button
    {
        if (!Page.IsValid)
        {
            return;
        }

        try
        {
            b.User_Id       = txtuserid.Text.Trim();
            b.Name          = TextBoxName.Text.Trim();
            b.Department_Id = DDLdeptname.SelectedValue;
            b.EmailId       = txtemailid.Text.Trim();
            b.InstituteId   = DDLinstitutename.SelectedValue;
            //b.BankAccountNumber = txtaccno.Text;
            if (txtDOB.Text != "01/01/0001" && txtDOB.Text != null && txtDOB.Text != "")
            {
                b.StudentDOB = Convert.ToDateTime(txtDOB.Text.Trim());
            }
            if (txtMobileNo.Text != "")
            {
                b.MobileNo = txtMobileNo.Text;
            }
            b.Sex         = DropDownListsex.SelectedValue;
            b.CreatedDate = DateTime.Now.ToString("yyyy-MM-dd");
            b.CreatedBy   = Session["UserId"].ToString();
            int retVal = bl.SaveStudentDetails(b);
            lblStatus.ForeColor = System.Drawing.Color.Green;
            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Student details saved successfully');window.location='" + Request.ApplicationPath + "/UserManagement/ManageStudent.aspx';</script>");

            GridViewUser.Visible     = false;
            btninsert.Enabled        = false;
            btninsert.Enabled        = true;
            popupPanelBaCode.Visible = false;
            b  = null;
            bl = null;
        }
        catch (Exception ex)
        {
            log.Error(ex.StackTrace);
            log.Error(ex.Message);

            log.Error("Error!!!!!!!!!!!!!!!! ");

            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>");
        }
    }
    protected void btn_insert(object sender, EventArgs e) //insert button
    {
        User           b  = new User();
        User_Mangement bl = new User_Mangement();

        if (!Page.IsValid)
        {
            return;
        }

        try
        {
            b.Department_Id = DDLdeptname.SelectedValue;
            b.InstituteId   = DDLinstitutename.SelectedValue;
            b.AutoApproved  = DropDownListAutoApprovee.SelectedValue;

            b.Remarks   = TextBoxRemarks.Text.Trim();
            b.UpdatedBy = Session["UserId"].ToString();

            int retVal = bl.InsertDepartmentInstituteAutoAppove(b);
            if (retVal == 1)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Data saved successfully');window.location='" + Request.ApplicationPath + "/UserManagement/InstDeptAutoApprove.aspx';</script>");

                btninsert.Enabled = false;
                btninsert.Enabled = true;
                b  = null;
                bl = null;
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>");
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.StackTrace);
            log.Error(ex.Message);

            log.Error("Error!!!!!!!!!!!!!!!! ");

            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>");
        }
    }
Example #5
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.selectExistingStudentDetails(txtuserid.Text.Trim());

            if (b.User_Id != null)
            {
                txtuserid.Text = b.User_Id;
                //TextBoxName.Enabled = false;
                TextBoxName.Text = b.Name;
                DDLinstitutename.SelectedValue = b.Institute_name.Trim();
                //DDLinstitutename.Enabled = false;
                DDLdeptname.Items.Clear();
                // DDLdeptname.Items.Add(new ListItem("--Select--", "", true));
                SqlDataSource1.SelectCommand = "select ClassCode,ClassName from SISClass";
                SqlDataSource1.DataBind();
                DDLdeptname.DataBind();
                DDLdeptname.SelectedValue = b.Department.Trim();
                DDLdeptname.DataBind();
                //DDLdeptname.Enabled = false;
                txtemailid.Text               = b.emailId;
                Session["OldmailID"]          = txtemailid.Text;
                DropDownListsex.SelectedValue = b.Sex;
                //txtaccno.Text = b.BankAccountNumber;
                if (b.StudentDOB.ToShortDateString() != "01/01/0001")
                {
                    txtDOB.Text = b.StudentDOB.ToShortDateString();
                }
                if (b.MobileNo != "")
                {
                    txtMobileNo.Text = b.MobileNo;
                }
                if (txtemailid.Text == "" || txtemailid.Text == null)
                {
                    txtemailid.Enabled = true;
                }
                else
                {
                    txtemailid.Enabled = true;
                }
                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;
                txtemailid.Text          = " ";
                //txtPassword.Text = " ";
                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>");
            }
        }
    }
Example #6
0
    protected void bindGridview(object sender, EventArgs e)
    {
        log.Debug("Inside bindGridview function");
        User_Mangement b  = new User_Mangement();
        DataSet        ds = b.GetHREmpData();

        if (ds.Tables[0].Rows.Count == 0)
        {
            log.Debug("No records to update or insert");
            ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('No HR record exists to update or add')</script>");
            return;
        }
        else
        {
            string connectionString = "";
            string isfilegenerate   = ConfigurationManager.AppSettings["UserExcelFileGenerate"].ToString();
            if (isfilegenerate == "Y")
            {
                Microsoft.Office.Interop.Excel.Application xlApp =
                    new Microsoft.Office.Interop.Excel.Application();
                Workbook  xlWorkbook  = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
                Sheets    xlSheets    = null;
                Worksheet xlWorksheet = null;
                object    misValue    = System.Reflection.Missing.Value;


                System.Data.DataTable dataTable = ds.Tables[0];
                int rowNo    = dataTable.Rows.Count;
                int columnNo = dataTable.Columns.Count;
                int colIndex = 0;

                //Create Excel Sheets
                xlSheets    = xlWorkbook.Sheets;
                xlWorksheet = (Worksheet)xlSheets.Add(xlSheets[1],
                                                      Type.Missing, Type.Missing, Type.Missing);
                //xlWorksheet.Name = dataSet.DataSetName;

                //Generate Field Names
                foreach (DataColumn dataColumn in dataTable.Columns)
                {
                    colIndex++;
                    xlApp.Cells[1, colIndex] = dataColumn.ColumnName;
                }

                object[,] objData = new object[rowNo, columnNo];

                //Convert DataSet to Cell Data
                for (int row = 0; row < rowNo; row++)
                {
                    for (int col = 0; col < columnNo; col++)
                    {
                        objData[row, col] = dataTable.Rows[row][col];
                    }
                }

                //Add the Data
                Range range = xlWorksheet.Range[xlApp.Cells[2, 1], xlApp.Cells[rowNo + 1, columnNo]];
                range.Value2 = objData;



                //Remove the Default Worksheet
                ((Worksheet)xlApp.ActiveWorkbook.Sheets[xlApp.ActiveWorkbook.Sheets.Count]).Delete();

                string servername       = ConfigurationManager.AppSettings["ServerName"].ToString();
                string domainame        = ConfigurationManager.AppSettings["DomainName"].ToString();
                string username         = ConfigurationManager.AppSettings["UserName"].ToString();
                string password         = ConfigurationManager.AppSettings["Password"].ToString();
                string mainpath         = ConfigurationManager.AppSettings["UploadUserPath"].ToString();
                string timestamp        = DateTime.Now.ToString("yyyy-MM-dd-hh_mm_ss");
                string ExcelFileVersion = ConfigurationManager.AppSettings["ExcelFileVersion"].ToString();
                string FileName         = "HRUserData" + timestamp + ExcelFileVersion;
                using (NetworkShareAccesser.Access(servername, domainame, username, password))
                {
                    if (Directory.Exists(mainpath))
                    {
                        path = Path.Combine(mainpath, FileName);
                        //  xlWorkbook.SaveAs(FileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                        xlWorkbook.SaveAs(path,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          XlSaveAsAccessMode.xlNoChange,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value);

                        xlWorkbook.Close();
                        xlApp.Quit();
                    }
                    else
                    {
                        Directory.CreateDirectory(mainpath);
                        path = Path.Combine(mainpath, FileName);
                        //  xlWorkbook.SaveAs(FileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                        xlWorkbook.SaveAs(path,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          XlSaveAsAccessMode.xlNoChange,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value,
                                          System.Reflection.Missing.Value);

                        xlWorkbook.Close();
                        xlApp.Quit();
                    }
                }
            }
            //string query = "SELECT * FROM [Sheet2$]";
            //connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
            //OleDbConnection conn = new OleDbConnection(connectionString);
            //if (conn.State == ConnectionState.Closed)
            //    conn.Open();
            //OleDbCommand cmd = new OleDbCommand(query, conn);
            //OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            //DataSet ds1 = new DataSet();
            //da.Fill(ds1);
            GridExcelData.DataSource = ds.Tables[0];
            GridExcelData.DataBind();
            //da.Dispose();
            //conn.Close();
            //conn.Dispose();
        }
    }
Example #7
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>");
            }
        }
    }