Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            FilteredTextBoxExtender10.ValidChars = FilteredTextBoxExtender10.ValidChars + "\r\n";
            if (Session["uid"] != null)
            {
                if (!IsPostBack)
                {
                    //add form 2

                    Show_form2();



                    //end form 2
                    div_msg.Visible = false;
                    txtEndDate.Text = DateTime.Now.AddYears(-12).ToString("dd/MM/yyyy");
                    if (!IsPostBack)
                    {
                        div_msg.Visible = false;
                        try
                        {
                            string StrQuery2 = "select id,name from tblStatesMaster where countryId='" + 101 + "' ORDER BY name";
                            dbContext.BindDropDownlist(StrQuery2, ref ddl_state);
                            ddl_city.Items.Clear();
                            ddl_city.Items.Insert(0, "--Select--");

                            string StrQueryExe = "select id,exeName from tblExecutive where status ='ACTIVE'";
                            dbContext.BindDropDownlist(StrQueryExe, ref ddl_ename);

                            txt_email.Text = Session["email"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex);
                            // if condition fails then user will get following message
                            div_msg.Visible             = true;
                            div_msg.Attributes["class"] = "alert alert-danger";
                            div_msg.InnerText           = "Something wrong on form loading. Please Try again." + ex.Message;
                        }
                    }
                }
            }
            else
            {
                Response.Redirect("~/login.aspx", false);
            }
        }
        catch (Exception ex)
        {
            Log.Error(ex);
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GridView1.SelectedIndex = -1;
        if (!IsPostBack)
        {
            lbl_msg.Visible = false;
            BindGridView();

            string StrDepartment = "select deptId, deptName from tbldepartment";
            dbContext.BindDropDownlist(StrDepartment, ref ddlDepartment);
            dbContext.BindDropDownlist(StrDepartment, ref ddlCDepartment);

            string StrCourse = "select courseId, courseNumber from tblcourse";
            dbContext.BindDropDownlist(StrCourse, ref ddlCourseNumber);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //only first time execuite on below code
        if (!IsPostBack)
        {
            clear_data();
            FillGrid();
            try
            {
                string StrDepartment = "SELECT Distinct deptId, deptName FROM tbldepartment";
                dbContext.BindDropDownlist(StrDepartment, ref ddlDepartment);

                string StrCourse = "SELECT Distinct courseId, courseName FROM tblcourse";
                dbContext.BindDropDownlist(StrCourse, ref ddlCourseName);

                //string constr = ConfigurationManager.ConnectionStrings["MySql_ConnectionString"].ConnectionString;
                //using (MySqlConnection con = new MySqlConnection(constr))
                //{
                //    string com = "SELECT Distinct deptId, deptName FROM tbldepartment";
                //    MySqlDataAdapter adpt = new MySqlDataAdapter(com, con);
                //    DataTable dt = new DataTable();
                //    adpt.Fill(dt);
                //    ddlDepartment.DataSource = dt;
                //    ddlDepartment.SelectedValue = null;
                //    ddlDepartment.DataBind();

                //    ddlDepartment.DataTextField = "deptName";
                //    ddlDepartment.DataValueField = "deptId";

                //    ddlDepartment.DataBind();
                //}
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
    }
Beispiel #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            courseId = Convert.ToInt32(Request.QueryString["id"]);


            string StrDepartment = "select deptId, deptName from tbldepartment";
            dbContext.BindDropDownlist(StrDepartment, ref ddlDepartment);

            string StrCourse = "select courseId, courseNumber from tblcourse";
            dbContext.BindDropDownlist(StrCourse, ref ddlCourseNumber);
            // dbContext.BindDropDownlist(StrCourse, ref ddlCourseStatus);

            string StrClassroom = "select classroomId, classroomNumber from tblclassroom";
            dbContext.BindDropDownlist(StrClassroom, ref ddlClassRoom);


            string constr = ConfigurationManager.ConnectionStrings["MySql_ConnectionString"].ConnectionString;
            using (MySqlConnection con = new MySqlConnection(constr))
            {
                string strcmd = "SELECT A.courseId, A.courseNumber, A.courseName, A.courseLevel, A.credits, B.deptName, A.status as status, A.term, A.credits, B.deptName from tblcourse as A " +
                                "LEFT OUTER JOIN tbldepartment as B on B.deptId = A.deptId " +
                                "WHERE A.courseId = " + courseId + " ";
                DataSet ds = dbContext.ExecDataSet(strcmd);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    ddlDepartment.SelectedValue    = ds.Tables[0].Rows[0][5].ToString();
                    ddlCourseNumber.SelectedValue  = ds.Tables[0].Rows[0]["courseNumber"].ToString();
                    txtCourseName.Text             = ds.Tables[0].Rows[0]["courseName"].ToString();
                    ddlCourseStatus.SelectedValue  = ds.Tables[0].Rows[0]["status"].ToString();
                    ddlCourseLevel.SelectedValue   = ds.Tables[0].Rows[0]["courseLevel"].ToString();
                    ddlCourseCredits.SelectedValue = ds.Tables[0].Rows[0]["credits"].ToString();
                    ddlCourseTerm.SelectedValue    = ds.Tables[0].Rows[0]["term"].ToString();

                    if (ds.Tables[0].Rows[0]["status"].ToString() == "1")
                    {
                        lblCourseStatus.Text     = "Active";
                        btnCourseStatus.Text     = "DEACTIVE";
                        btnCourseStatus.CssClass = "btn btn-danger btn-sm btn-block";
                    }
                    else
                    {
                        lblCourseStatus.Text     = "Deactive";
                        btnCourseStatus.Text     = "ACTIVE";
                        btnCourseStatus.CssClass = "btn btn-success btn-sm btn-block";
                    }
                }

                //MySqlCommand cmd = new MySqlCommand(strcmd, con);
                //con.Open();
                //MySqlDataReader dr = cmd.ExecuteReader();
                //if (dr.HasRows)
                //{
                //    dr.Read();
                //    ddlDepartment.SelectedValue = dr["deptName"].ToString();
                //    ddlCourseNumber.SelectedValue = dr["courseNumber"].ToString();
                //}
            }
        }
        catch (Exception ex)
        {
            Log.Error(ex);
        }
    }