Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         diverror.Visible = false;
         if (!IsPostBack)
         {
             DataSet  ds  = Contacts.GroupContactSelectAll();
             int      num = ds.Tables[0].Rows.Count;
             ListItem Item;
             Item = new ListItem("Hãy chọn nhóm liên hệ", "0");
             slgroup.Items.Add(Item);
             for (int i = 0; i < num; i++)
             {
                 Item = new ListItem(ds.Tables[0].Rows[i]["name"].ToString(), ds.Tables[0].Rows[i]["id"].ToString());
                 slgroup.Items.Add(Item);
             }
             ds   = Contacts.LocationContactSelectAll();
             num  = ds.Tables[0].Rows.Count;
             Item = new ListItem("Hãy chọn khu vực liên hệ", "0");
             sllocation.Items.Add(Item);
             for (int i = 0; i < num; i++)
             {
                 Item = new ListItem(ds.Tables[0].Rows[i]["name"].ToString(), ds.Tables[0].Rows[i]["id"].ToString());
                 sllocation.Items.Add(Item);
             }
         }
     }
     catch
     {
         Response.Redirect("AdminWebsite.aspx?menu=contact");
     }
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         diverror.Visible = false;
         id = int.Parse(Request.QueryString["id"].ToString());
         if (!IsPostBack)
         {
             DataSet dscontact = Contacts.ContactAdminSelectIdName(id, "ContactAdminSelectIdName");
             if (dscontact.Tables.Count > 0 && dscontact.Tables[0].Rows.Count > 0)
             {
                 string idgroup    = dscontact.Tables[0].Rows[0]["idtype"].ToString();
                 string idlocation = dscontact.Tables[0].Rows[0]["idlocation"].ToString();
                 txttitle.Value       = dscontact.Tables[0].Rows[0]["name"].ToString();
                 txtdes.Value         = dscontact.Tables[0].Rows[0]["des"].ToString();
                 txtaddress.Value     = dscontact.Tables[0].Rows[0]["address"].ToString();
                 txttimeservice.Value = dscontact.Tables[0].Rows[0]["timeservice"].ToString();
                 txtphone.Value       = dscontact.Tables[0].Rows[0]["phone"].ToString();
                 txtemail.Value       = dscontact.Tables[0].Rows[0]["email"].ToString();
                 txtdelegate.Value    = dscontact.Tables[0].Rows[0]["delegate"].ToString();
                 txtfax.Value         = dscontact.Tables[0].Rows[0]["fax"].ToString();
                 DataSet  ds  = Contacts.GroupContactSelectAll();
                 int      num = ds.Tables[0].Rows.Count;
                 ListItem Item;
                 Item = new ListItem("Hãy chọn nhóm liên hệ", "0");
                 slgroup.Items.Add(Item);
                 for (int i = 0; i < num; i++)
                 {
                     Item = new ListItem(ds.Tables[0].Rows[i]["name"].ToString(), ds.Tables[0].Rows[i]["id"].ToString());
                     slgroup.Items.Add(Item);
                     if (ds.Tables[0].Rows[i]["id"].ToString().Equals(idgroup))
                     {
                         slgroup.Items[i + 1].Selected = true;
                     }
                 }
                 ds   = Contacts.LocationContactSelectAll();
                 num  = ds.Tables[0].Rows.Count;
                 Item = new ListItem("Hãy chọn khu vực liên hệ", "0");
                 sllocation.Items.Add(Item);
                 for (int i = 0; i < num; i++)
                 {
                     Item = new ListItem(ds.Tables[0].Rows[i]["name"].ToString(), ds.Tables[0].Rows[i]["id"].ToString());
                     sllocation.Items.Add(Item);
                     if (ds.Tables[0].Rows[i]["id"].ToString().Equals(idlocation))
                     {
                         sllocation.Items[i + 1].Selected = true;
                     }
                 }
             }
             else
             {
                 Response.Redirect("AdminWebsite.aspx?menu=contact");
             }
         }
     }
     catch
     {
         Response.Redirect("AdminWebsite.aspx?menu=contact");
     }
 }