Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["name"] == null)
                {
                    Session["prevUrl"] = Request.Url;
                    Response.Redirect("~/loginPage.aspx");
                }
                else
                {
                    string username = Session["name"].ToString();
                    this.Label8.Text = string.Format("Hi {0}", Session["name"].ToString() + "!");
                    // Label8.Visible = false;
                    //  Label8.Text = username;

                    string        connString = ConfigurationManager.ConnectionStrings["tomms_prodConnectionString"].ConnectionString;
                    SqlConnection con        = null;

                    try
                    {
                        con = new SqlConnection(connString);

                        /*For Zone Dropdown Load*/
                        string com01 = "select distinct  ast_loc_zone , ast_loc_zone from ast_loc (nolock)";

                        SqlDataAdapter adptzo = new SqlDataAdapter(com01, con);
                        DataTable      dtzo   = new DataTable();
                        adptzo.Fill(dtzo);
                        DropDownZone.DataSource = dtzo;
                        DropDownZone.DataBind();
                        DropDownZone.DataTextField  = "ast_loc_zone";
                        DropDownZone.DataValueField = "ast_loc_zone";
                        DropDownZone.DataBind();
                        DropDownZone.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For State Dropdown Load*/
                        string com = "Select RowID, ast_lvl_ast_lvl  from ast_lvl (nolock)";

                        SqlDataAdapter adpt = new SqlDataAdapter(com, con);
                        DataTable      dt   = new DataTable();
                        adpt.Fill(dt);
                        DropDownState.DataSource = dt;
                        DropDownState.DataBind();
                        DropDownState.DataTextField  = "ast_lvl_ast_lvl";
                        DropDownState.DataValueField = "RowID";
                        DropDownState.DataBind();
                        DropDownState.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For District Dropdown Load*/
                        DropDownDistrict.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For Circle Dropdown Load*/
                        DropDowncircle.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For Clinic Cate Dropdown Load*/
                        DropDownCliniccat.Items.Insert(0, new ListItem("KESIHATAN", "1"));
                        DropDownCliniccat.Items.Insert(0, new ListItem("PERGIGIAN", "2"));
                        DropDownCliniccat.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For BE Category Cate Dropdown Load*/
                        string com4 = "select ast_grp_grp_cd , ast_grp_category  from ast_grp (nolock) order by ast_grp_category ";

                        SqlDataAdapter adpt4 = new SqlDataAdapter(com4, con);
                        DataTable      dt4   = new DataTable();
                        adpt4.Fill(dt4);
                        DropDownBECate.DataSource = dt4;
                        DropDownBECate.DataBind();
                        DropDownBECate.DataTextField  = "ast_grp_category";
                        DropDownBECate.DataValueField = "ast_grp_grp_cd";
                        DropDownBECate.DataBind();
                        DropDownBECate.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For BE Category Cate Dropdown Load*/
                        string com5 = "select wrk_sts_status ,wrk_sts_desc from wrk_sts (nolock) where wrk_sts_disable_flag = 0";

                        SqlDataAdapter adpt5 = new SqlDataAdapter(com5, con);
                        DataTable      dt5   = new DataTable();
                        adpt5.Fill(dt5);
                        DropDownList1.DataSource = dt5;
                        DropDownList1.DataBind();
                        DropDownList1.DataTextField  = "wrk_sts_desc";
                        DropDownList1.DataValueField = "wrk_sts_status";
                        DropDownList1.DataBind();
                        DropDownList1.Items.Insert(0, new ListItem("ALL", "0"));
                    }
                    catch (Exception ex)
                    {
                        //log error
                        //display friendly error to user
                        string msg = "Insert Error:";
                        msg += ex.Message;
                        throw new Exception(msg);
                    }
                    finally
                    {
                        con.Close();
                    }
                }
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["name"] == null)
                {
                    Session["prevUrl"] = Request.Url;
                    Response.Redirect("~/loginPage.aspx");
                }
                else
                {
                    string username = Session["name"].ToString();
                    this.Label8.Text = string.Format("Hi {0}", Session["name"].ToString() + "!");
                    //Label8.Visible = false;
                    //Label8.Text = username;


                    string        connString = ConfigurationManager.ConnectionStrings["tomms_prodConnectionString"].ConnectionString;
                    SqlConnection con        = null;

                    try
                    {
                        con = new SqlConnection(connString);
                        /*For State Dropdown Load*/
                        string com = "Select RowID, ast_lvl_ast_lvl  from ast_lvl (nolock)";

                        SqlDataAdapter adpt = new SqlDataAdapter(com, con);
                        DataTable      dt   = new DataTable();
                        adpt.Fill(dt);
                        DropDownState.DataSource = dt;
                        DropDownState.DataBind();
                        DropDownState.DataTextField  = "ast_lvl_ast_lvl";
                        DropDownState.DataValueField = "RowID";
                        DropDownState.DataBind();
                        DropDownState.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For District Dropdown Load*/

                        //string com1 = "select RowID , ast_loc_ast_loc from  ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "'";
                        //
                        //SqlDataAdapter adpt1 = new SqlDataAdapter(com1, con);
                        //DataTable dt1 = new DataTable();
                        //adpt1.Fill(dt1);
                        //DropDownDistrict.DataSource = dt1;
                        //DropDownDistrict.DataBind();
                        //DropDownDistrict.DataTextField = "ast_loc_ast_loc";
                        //DropDownDistrict.DataValueField = "RowID";
                        //DropDownDistrict.DataBind();
                        DropDownDistrict.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For Circle Dropdown Load*/

                        //string Com2 = "select RowID , ast_loc_circle from  ast_loc (nolock) where ast_loc_state = '" + DropDownState.SelectedItem.Text + "' and ast_loc_ast_loc = '" + DropDownDistrict.SelectedItem.Text + "'";
                        //
                        //SqlDataAdapter adpt2 = new SqlDataAdapter(Com2, con);
                        //DataTable dt2 = new DataTable();
                        //adpt2.Fill(dt2);
                        //DropDowncircle.DataSource = dt2;
                        //DropDowncircle.DataBind();
                        //DropDowncircle.DataTextField = "ast_loc_circle";
                        //DropDowncircle.DataValueField = "RowID";
                        //DropDowncircle.DataBind();
                        DropDowncircle.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For Clinic Cate Dropdown Load*/
                        DropDownCliniccat.Items.Insert(0, new ListItem("KESIHATAN", "1"));
                        DropDownCliniccat.Items.Insert(0, new ListItem("PERGIGIAN", "2"));
                        DropDownCliniccat.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For Ownership Dropdown Load*/
                        DropDownOwner.Items.Insert(0, new ListItem("Existing", "1"));
                        DropDownOwner.Items.Insert(0, new ListItem("New Biomedical", "2"));
                        DropDownOwner.Items.Insert(0, new ListItem("Purchase Biomedical", "3"));
                        DropDownOwner.Items.Insert(0, new ListItem("ALL", "0"));

                        /*For BE Category Cate Dropdown Load*/
                        string com4 = "select ast_grp_grp_cd , ast_grp_category  from ast_grp (nolock) order by ast_grp_category ";

                        SqlDataAdapter adpt4 = new SqlDataAdapter(com4, con);
                        DataTable      dt4   = new DataTable();
                        adpt4.Fill(dt4);
                        DropDownBECate.DataSource = dt4;
                        DropDownBECate.DataBind();
                        DropDownBECate.DataTextField  = "ast_grp_category";
                        DropDownBECate.DataValueField = "ast_grp_grp_cd";
                        DropDownBECate.DataBind();
                        DropDownBECate.Items.Insert(0, new ListItem("ALL", "0"));
                    }
                    catch (Exception ex)
                    {
                        //log error
                        //display friendly error to user
                        string msg = "Insert Error:";
                        msg += ex.Message;
                        throw new Exception(msg);
                    }
                    finally
                    {
                        con.Close();
                    }
                }
            }
        }