Exemplo n.º 1
0
 protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         int     id       = Convert.ToInt32(TextBox1.Text);
         cliente Eliminar = conectar.cliente.FirstOrDefault
                                (a => a.id_cliente == id);
         if (Eliminar != null)
         {
             conectar.DeleteObject(Eliminar);
             conectar.SaveChanges();
             limpiar();
             Label1.Text = "Registro eliminado";
             GridView1.DataBind();
             TextBox7.Focus();
         }
         else
         {
             Label10.Text = "La identificacion no existe";
         }
     }
     catch (Exception ex)
     {
         Label10.Text = "No se ha eliminado..." + ex.Message;
     }
 }
Exemplo n.º 2
0
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            int     id         = Convert.ToInt32(TextBox1.Text);
            cliente actualizar = conectar.cliente.FirstOrDefault
                                     (a => a.id_cliente == id);
            if (actualizar != null)
            {
                actualizar.nombre_cliente    = Convert.ToString(TextBox2.Text);
                actualizar.apellido_cliente  = Convert.ToString(TextBox3.Text);
                actualizar.telefono_cliente  = Convert.ToString(TextBox5.Text);
                actualizar.direccion_cliente = Convert.ToString(TextBox7.Text);


                conectar.SaveChanges();
                limpiar();
                Label1.Text = "Registro actualizado";
                GridView1.DataBind();
                TextBox7.Focus();
            }
            else
            {
                Label10.Text = "La identificacion no existe";
            }
        }
        catch (Exception ex)
        {
            Label10.Text = "No se ha podido Modificar..." + ex.Message;
        }
    }
Exemplo n.º 3
0
 private void InsertUser()
 {
     try
     {
         if (CurrentGroup != null && (bool)CurrentGroup.Fields["IsAdmin"].Value)
         {
             TextBox7.Focus();
             EnableUserButtons(true, true, false, false);
             ListBox6.Enabled           = false;
             ListBox5.Enabled           = false;
             TextBox7.Text              = "";
             TextBox9.Text              = "";
             TextBox8.Text              = "";
             TextBox10.Text             = "";
             TextBox11.Text             = "";
             ListBox6.SelectedIndex     = -1;
             ViewState["IncluiUsuario"] = true;
             TextBox9.Enabled           = true;
             TextBox7.Enabled           = true;
             TextBox8.Enabled           = true;
             TextBox10.Enabled          = true;
         }
     }
     catch
     {
     }
 }
 private void limpar()
 {
     txtdescricao.Clear(); txtprecouni.Clear(); txtquant.Clear(); txttotal.Clear(); buscprods.Clear();
     comboBox2.SelectedIndex = -1; txtcli.Clear(); cbmfmpg.SelectedIndex = -1; textBox3.Clear();
     TextBox6.Clear(); TextBox7.Clear(); txtvalortotal.Clear();
     datalistado.Rows.Clear();
 }
Exemplo n.º 5
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     //sql = "Select * From receipt where name = '" + TextBox2.Text + "' and number = '" + TextBox3.Text + "'";
     Label4.Visible   = Label5.Visible = Label6.Visible = Label7.Visible = Label8.Visible = Label9.Visible = true;
     TextBox5.Visible = TextBox6.Visible = TextBox7.Visible = TextBox8.Visible = TextBox9.Visible = true;
     RequiredFieldValidator5.Visible = RequiredFieldValidator6.Visible = RequiredFieldValidator7.Visible = RequiredFieldValidator8.Visible = RequiredFieldValidator9.Visible = true;
     RequiredFieldValidator5.Visible = true;
     Button2.Visible = true;
     Label4.Text     = " Enter new  receipt";
     Label5.Text     = " Name: ";
     TextBox5.Focus();
     RequiredFieldValidator5.ControlToValidate = "TextBox5";
     RequiredFieldValidator5.ErrorMessage      = "* fill Name";
     Label6.Text = " Company: ";
     TextBox6.Focus();
     RequiredFieldValidator6.ControlToValidate = "TextBox6";
     RequiredFieldValidator6.ErrorMessage      = "* fill Company";
     Label7.Text = " Number: ";
     TextBox7.Focus();
     RequiredFieldValidator7.ControlToValidate = "TextBox7";
     RequiredFieldValidator7.ErrorMessage      = "* fill Number";
     Label8.Text = " Arrears: ";
     TextBox8.Focus();
     RequiredFieldValidator8.ControlToValidate = "TextBox8";
     RequiredFieldValidator8.ErrorMessage      = "* fill Arrears";
     Label9.Text = " Suma: ";
     TextBox9.Focus();
     RequiredFieldValidator9.ControlToValidate = "TextBox9";
     RequiredFieldValidator9.ErrorMessage      = "* fill Suma";
     Button2.Text = "Ready ";
 }
Exemplo n.º 6
0
 private void limpiar()
 {
     TextBox1.Clear();
     TextBox4.Clear();
     textBox5.Clear();
     TextBox6.Clear();
     TextBox7.Clear();
     TextBox3.Clear();
 }
Exemplo n.º 7
0
 public void clear()
 {
     TextBox9.Clear();
     TextBox7.Clear();
     TextBox15.Clear();
     TextBox13.Clear();
     TextBox11.Clear();
     TextBox10.Clear();
     comboBox1.Text = "";
     comboBox2.Text = "";
 }
Exemplo n.º 8
0
 public void ClearTextBoxes()
 {
     TextBox1.Clear();
     TextBox2.Clear();
     TextBox3.Clear();
     TextBox4.Clear();
     TextBox5.Clear();
     TextBox6.Clear();
     TextBox7.Clear();
     TextBox8.Clear();
     TextBoxID.Clear();
 }
Exemplo n.º 9
0
 private void TextBox7_Leave(object sender, EventArgs e)
 {
     if (TextBox7.Text == "")
     {
         EP.SetError(TextBox7, "Fill the first");
         TextBox7.Focus();
     }
     else
     {
         EP.Clear();
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     datalistado.Rows.Clear();
     txtvalortotal.Clear();
     txtdescricao.Clear();
     txtprecouni.Clear();
     txtquant.Clear();
     txttotal.Clear();
     txtvalortotal.Clear();
     buscprods.Clear();
     textBox3.Clear();
     TextBox6.Clear();
     TextBox7.Clear();
 }
Exemplo n.º 11
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Label8.Text = "";
        if (TextBox2.Equals("") || TextBox4.Equals("") || TextBox7.Equals("") || TextBox8.Equals(""))
        {
            //do nothing as either student or book has failed some criteria
        }
        else
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            con.Open();

            String     str3 = "select * from card_rules";
            SqlCommand cmd3 = new SqlCommand(str3, con);
            cmd3.ExecuteNonQuery();

            SqlDataAdapter da3 = new SqlDataAdapter();
            da3.SelectCommand = cmd3;

            DataSet ds3 = new DataSet();
            da3.Fill(ds3);

            int        tl   = Convert.ToInt32(ds3.Tables[0].Rows[0]["time_limit"].ToString());
            int        df   = Convert.ToInt32(ds3.Tables[0].Rows[0]["daily_fine"].ToString());
            String     str2 = "SELECT CONVERT (date, SYSDATETIME())";
            SqlCommand cmd2 = new SqlCommand(str2, con);
            cmd2.ExecuteNonQuery();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd2;
            DataSet ds = new DataSet();
            da.Fill(ds);
            String issuedate = ds.Tables[0].Rows[0][0].ToString();



            String     str = "insert into issuebook values('" + TextBox1.Text + "','" + TextBox3.Text + "','" + TextBox8.Text + "','" + issuedate + "')";
            SqlCommand cmd = new SqlCommand(str, con);
            //cmd.Parameters.AddWithValue("@accno", TextBox1.Text);
            //cmd.Parameters.AddWithValue("@id", TextBox3.Text);
            //cmd.Parameters.AddWithValue("@bname", TextBox8.Text);
            //cmd.Parameters.AddWithValue("@issuedate", issuedate);
            int i = cmd.ExecuteNonQuery();

            if (i == 1)
            {
                Label8.Text = "Book with Accession No: " + TextBox1.Text + " assigned to " + TextBox3.Text + " and you have to return in " + tl + " days otherwise penalty per day: " + df + " Rupees";
            }
            con.Close();
        }
    }
Exemplo n.º 12
0
        protected void TextBox12_TextChanged(object sender, EventArgs e)
        {
            cmd.CommandText = "select count(*)+1 from invoices";
            object o = cmd.ExecuteScalar();

            Session.Add("InvoiceNo", o);
            double d1 = Convert.ToDouble(TextBox10.Text);
            double d2 = Convert.ToDouble(TextBox12.Text);
            double d3 = d1 * d2;

            TextBox13.Text = d3.ToString();
            Label6.Text    = d3.ToString();
            Label13.Text   = d3.ToString();
            System.Data.DataRow dr = ds.invoiceitems.NewRow();//data set me value save ki
            dr[0] = o.ToString();
            dr[1] = TextBox7.Text;
            dr[2] = TextBox8.Text;
            dr[3] = TextBox9.Text;
            dr[4] = TextBox10.Text;
            dr[5] = TextBox11.Text;
            dr[6] = TextBox12.Text;
            dr[7] = TextBox13.Text;
            ds.invoiceitems.Rows.Add(dr);
            GridView1.DataBind();
            cmd.CommandText = "insert into invoiceitems values(@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8)";//dataset ki value db me save kari
            cmd.Parameters.AddWithValue("p1", o);
            cmd.Parameters.AddWithValue("p2", TextBox7.Text);
            cmd.Parameters.AddWithValue("p3", TextBox8.Text);
            cmd.Parameters.AddWithValue("p4", TextBox9.Text);
            cmd.Parameters.AddWithValue("p5", TextBox10.Text);
            cmd.Parameters.AddWithValue("p6", TextBox11.Text);
            cmd.Parameters.AddWithValue("p7", TextBox12.Text);
            cmd.Parameters.AddWithValue("p8", TextBox13.Text);
            cmd.ExecuteNonQuery();//agar yaha problem hui to db me datatype ki problem hogi

            cmd.Parameters.Clear();
            double d4 = Convert.ToDouble(TextBox13.Text) + Convert.ToDouble(Label1.Text);

            Label1.Text    = d4.ToString("F2");
            Label6.Text    = Label1.Text;
            TextBox7.Text  = "";
            TextBox8.Text  = "";
            TextBox9.Text  = "";
            TextBox10.Text = "";
            TextBox11.Text = "";
            TextBox12.Text = "";
            TextBox13.Text = "";
            TextBox7.Focus();
        }
Exemplo n.º 13
0
 private void Button3_Click(object sender, EventArgs e)
 {
     TextBox1.Clear();
     TextBox2.Clear();
     TextBox3.Clear();
     TextBox4.Clear();
     TextBox5.Clear();
     TextBox6.Clear();
     TextBox7.Clear();
     TextBox8.Clear();
     TextBox9.Clear();
     ComboBox1.Items.Clear();
     RadioButton1.Checked = false;
     RadioButton2.Checked = false;
 }
Exemplo n.º 14
0
 protected void LinkButton2_Click(object sender, EventArgs e)
 {
     Session["change_validate"]  = "false";
     Session["main_validate"]    = "false";
     Session["restore_validate"] = "false";
     if (Panel2.Visible == false)
     {
         Panel2.Visible = true;
         Panel1.Visible = false;
         TextBox7.Focus();
     }
     else
     {
         Panel2.Visible = false;
     }
 }
        private void TextBox6_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            char c = Convert.ToChar(e.Text);

            if (Char.IsControl(c))
            {
                TextBox7.Focus();
                return;
            }
            if (Char.IsLetter(c) || Char.IsSurrogate(c))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }
Exemplo n.º 16
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.IsValid)
        {
            con.Open();
            SqlCommand    cmd1 = new SqlCommand("Select * From user1 Where username='******'", con);
            SqlDataReader dr   = cmd1.ExecuteReader();
            if (dr.HasRows == true)
            {
                dr.Close();
                Label7.Text      = "User Name Already Exist";
                Label7.ForeColor = Color.Red;
                TextBox7.Focus();
                con.Close();
            }
            else
            {
                System.IO.Directory.CreateDirectory(MapPath("~/User/" + TextBox7.Text));
                dr.Close();
                SqlCommand cmd = new SqlCommand("insert into user1 values('" + TextBox7.Text + "','" + TextBox5.Text + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + RadioButtonList1.SelectedIndex + "','" + TextBox8.Text + "')", con);
                cmd.CommandType = CommandType.Text;

                try
                {
                    cmd.ExecuteNonQuery();

                    //Response.Write("Data inserted successfully");
                    Response.Redirect("Login.aspx");
                    con.Close();

                    clear();
                }

                catch (Exception ex)
                {
                    Response.Write(ex.Message);

                    clear();
                }
            }
        }
    }
Exemplo n.º 17
0
 private void Button2_Click(object sender, EventArgs e)
 {
     TextBox1.Clear();
     TextBox2.Clear();
     TextBox3.Clear();
     TextBox4.Clear();
     TextBox5.Clear();
     TextBox6.Clear();
     TextBox7.Clear();
     TextBox8.Clear();
     TextBox9.Clear();
     TextBox10.Clear();
     ComboBox1.Text       = "Selecione...";
     ComboBox2.Text       = "Selecione...";
     CheckBox1.Checked    = false;
     CheckBox2.Checked    = false;
     CheckBox3.Checked    = false;
     RadioButton1.Checked = false;
     RadioButton2.Checked = false;
     TextBox1.Focus();
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     // '"+var+"'
     if (TextBox7.Text == TextBox8.Text)
     {
         cn.Open();
         OleDbCommand cmd = new OleDbCommand();
         cmd.Connection  = cn;
         cmd.CommandText = "insert into registration (id,name,dept,batch,email,contact,pass,repass,dateofreg) values('" + TextBox3.Text.ToString() + "','" + TextBox2.Text.ToString() + "','" + DropDownList1.Text.ToString() + "','" + TextBox4.Text.ToString() + "','" + TextBox5.Text.ToString() + "','" + TextBox6.Text.ToString() + "','" + TextBox7.Text.ToString() + "','" + TextBox8.Text.ToString() + "','" + TextBox9.Text.ToString() + "')";
         Label11.Text    = "Succesfully Registred";
         Label10.Text    = "";
         cmd.ExecuteNonQuery();
         cn.Close();
     }
     else
     {
         Label10.Text  = "Password and Confirmed password doesnt match";
         TextBox7.Text = "";
         TextBox7.Text = "";
         TextBox7.Focus();
     }
 }
Exemplo n.º 19
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        string firstName, lastName, id, password, cellPhone, workPhone, cellProvider, category;
        bool   encryption;

        Label2.Visible = true;
        string url = TextBox11.Text;

        if (url == null || url.Length == 0)
        {
            Label2.Text = "Enter Valid Url";
            TextBox11.Focus();
            return;
        }
        firstName = TextBox4.Text;
        if (firstName == null || firstName.Length == 0)
        {
            Label2.Text = "Enter First Name";
            TextBox4.Focus();
            return;
        }

        lastName = TextBox5.Text;
        if (lastName == null || lastName.Length == 0)
        {
            Label2.Text = "Enter Last Name";
            TextBox5.Focus();
            return;
        }
        id = TextBox6.Text;
        if (id == null || id.Length == 0)
        {
            Label2.Text = "Enter Id";
            TextBox6.Focus();
            return;
        }
        password = TextBox7.Text;
        if (password == null || password.Length == 0)
        {
            Label2.Text = "Enter Password";
            TextBox7.Focus();
            return;
        }

        workPhone = TextBox8.Text;
        if (workPhone == null || workPhone.Length == 0)
        {
            Label2.Text = "Enter Work Phone";
            TextBox8.Focus();
            return;
        }
        cellPhone = TextBox9.Text;
        if (cellPhone == null || cellPhone.Length == 0)
        {
            Label2.Text = "Enter Cell Phone";
            TextBox9.Focus();
            return;
        }
        cellProvider = TextBox10.Text;

        /* if (cellProvider == null || cellProvider.Length == 0)
         * {
         *   Label2.Text = "Enter Cell Provider";
         *   TextBox10.Focus();
         *   return;
         * }*/

        category       = testSelect.Value;
        encryption     = CheckBox1.Checked;
        Label2.Visible = true;


        List <String> data = new List <string>();

        Label2.Text = category;

        data.Add(firstName);
        data.Add(lastName);
        data.Add(id);
        if (encryption)
        {
            EncryptionService.ServiceClient encryptSVC = new EncryptionService.ServiceClient();
            data.Add(encryptSVC.Encrypt(password));
        }
        else
        {
            data.Add(password);
        }
        data.Add(workPhone);
        data.Add(cellPhone);
        data.Add(category);
        data.Add(encryption.ToString());
        data.Add(cellProvider);



        XmlService.Service1Client svc = new XmlService.Service1Client();

        string response = svc.addPerson(data.ToArray(), url);

        Label2.Text = response;

        Button2.Focus();
    }
Exemplo n.º 20
0
        //監聽 Server 訊息 (Listening to the Server)
        private void Listen()
        {
            EndPoint ServerEP = (EndPoint)T.RemoteEndPoint; //Server 的 EndPoint

            byte[] B     = new byte[1023];                  //接收用的 Byte 陣列
            int    inLen = 0;                               //接收的位元組數目
            string Msg;                                     //接收到的完整訊息
            string St;                                      //命令碼
            string Str;                                     //訊息內容(不含命令碼)

            while (true)                                    //無限次監聽迴圈
            {
                try
                {
                    inLen = T.ReceiveFrom(B, ref ServerEP);//收聽資訊並取得位元組數
                }
                catch (Exception)
                {
                    T.Close();                                                                          //關閉通訊器
                    listBox1.Items.Clear();                                                             //清除線上名單
                    MessageBox.Show("伺服器斷線了!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information); //顯示斷線
                    button1.Enabled = true;                                                             //連線按鍵恢復可用
                    Th.Abort();                                                                         //刪除執行緒
                }

                Msg = Encoding.Default.GetString(B, 0, inLen); //解讀完整訊息
                St  = Msg.Substring(0, 1);                     //取出命令碼 (第一個字)
                Str = Msg.Substring(1);                        //取出命令碼之後的訊息
                switch (St)                                    //依命令碼執行功能
                {
                case "L":                                      //接收線上名單
                    listBox1.Items.Clear();                    //清除名單
                    string[] M = Str.Split(',');               //拆解名單成陣列
                    player = M;
                    for (int i = 0; i < M.Length; i++)
                    {
                        listBox1.Items.Add(M[i]);                                    //逐一加入名單
                    }
                    break;

                //接收廣播訊息
                case "1":
                    TextBox5.AppendText("(公開)" + Str + "\r\n");
                    break;

                case "2":

                    if (Ans.Equals(Str))
                    {
                        TextBox7.AppendText(User + ": Hit" + "\r\n");     //顯示訊息並換行
                        TextBox8.ReadOnly    = true;
                        metroButton2.Enabled = false;
                    }
                    else
                    {
                        TextBox7.AppendText(User + ":" + Str + "\r\n");     //顯示訊息並換行
                    }
                    break;

                case "3":                                       //接收私密訊息
                    TextBox5.AppendText("(私密)" + Str + "\r\n"); //顯示訊息並換行游標移到最後
                    break;

                case "5":
                    PointShape(Str);
                    break;

                case "A":    //答案
                    Ans = Str;
                    metroLabel3.Text = Ans;
                    break;

                case "C":    //cls
                    D.Shapes.Clear();
                    break;
                }
            }
        }
Exemplo n.º 21
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            HttpContext.Current.Server.ScriptTimeout = 600;
            Server.ScriptTimeout = 500;
            bool flag = true;

            string confrim_value = Request.Form["Confirm_Value"];

            if (TextBox4.Text == "")
            {
                Response.Write("<script>alert('Problem Cannot be Blank')</script>");
                TextBox4.Focus();
                flag = false;
            }

            if (TextBox6.Text == "")
            {
                Response.Write("<script>alert('Received Date Cannot be Blank')</script>");
                TextBox6.Focus();
                flag = false;
            }

            if (TextBox7.Text == "")
            {
                Response.Write("<script>alert('Requestor Email Cannot be Blank</script>");
                TextBox7.Focus();
                flag = false;
            }

            if ((TextBox8.Text == "") && (TextBox9.Text == ""))
            {
                Response.Write("<script>alert('TimeEntries cannot be Blank')</script>");
                TextBox4.Focus();
                flag = false;
            }

            if ((confrim_value == "YES") && (flag == true) && (CheckBox1.Checked == true))
            {
                int      Ref_No = Int32.Parse(TextBox1.Text);
                DateTime rec_da = System.DateTime.Now;
                if ((TextBox8.Text == "") || (TextBox9.Text == ""))
                {
                    TextBox8.Text = "00";
                    TextBox9.Text = "00";
                }
                string condate  = TextBox6.Text + " " + TextBox8.Text + ":" + TextBox9.Text + ":" + "00";
                string Rec_Date = Convert.ToDateTime(condate).ToString("yyyy/MM/dd HH:mm:ss");

                string   Prob_Desc     = TextBox4.Text;
                string   Type          = DropDownList2.SelectedItem.Text;
                string   Remarks       = DropDownList6.SelectedItem.Value;
                string   Req_Name      = TextBox2.Text;
                string   Com_Type      = DropDownList3.SelectedItem.Text;
                string   Req_Email     = TextBox7.Text;
                string   Req_Status    = DropDownList4.SelectedItem.Text;
                string   Act_Email     = DropDownList5.SelectedItem.Text;
                string   khidmat2      = ddlType.SelectedItem.Text;
                DateTime Escalate_Date = DateTime.Now;
                bool     msgflag       = false;

                bl c = new bl();
                try
                {
                    bool stat = c.addsrvreq(Ref_No, Rec_Date, Req_Name, Prob_Desc, Type, Com_Type, Req_Email, Req_Status, Remarks, Act_Email, khidmat2, Escalate_Date);
                    stat    = c.addsrvreq1(Ref_No, Rec_Date, Req_Name, Prob_Desc, Type, Com_Type, Req_Email, Req_Status, Remarks, Act_Email, khidmat2, Escalate_Date);
                    msgflag = true;
                }


                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Request Couldnt Be Added Try Again')", true);
                }

                if (msgflag)
                {
                    Response.Write("<script>alert('Request Added Successfully');</script>");
                }

                //if (Com_Type != "CONFIGMGMT")

                //{
                //    //email to buswani
                //    string email = "*****@*****.**";
                //    System.Net.Mail.MailMessage message3 = new System.Net.Mail.MailMessage();
                //    message3.To.Add(email);
                //    message3.Subject = "Mail from IT Help Desk";
                //    message3.From = new System.Net.Mail.MailAddress("*****@*****.**");
                //    message3.Body = "Dear       : Mr. Buswani  "
                //    + Environment.NewLine
                //    + Environment.NewLine
                //    + "IT Request Received from :   " + Req_Name + "    on this Date   :" + System.DateTime.Today.ToShortDateString()
                //    + Environment.NewLine
                //    + Environment.NewLine
                //    + "Category         :  " + Type +
                //    Environment.NewLine
                //    + "Reference No     :  " + Ref_No +
                //    Environment.NewLine +
                //    "Problem Desc      :  " + Prob_Desc
                //    + Environment.NewLine
                //    + Environment.NewLine
                //    + "Thank you."
                //    + Environment.NewLine
                //    + "Regards"
                //    + Environment.NewLine
                //    + "AeroLogica Sdn Bhd  "
                //    + Environment.NewLine
                //    + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";
                //    System.Net.Mail.SmtpClient smtp3 = new System.Net.Mail.SmtpClient("128.2.11.11");
                //    smtp3.Port = 25;

                //    smtp3.Send(message3);
                //    //end of buswani mail message
                //}

                //Response.Cookies[cookname] ["date"]  =Convert.ToString(System.DateTime.Now);
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(Act_Email);
                message.Subject = "Mail from IT Help Desk";
                message.From    = new System.Net.Mail.MailAddress("*****@*****.**");
                if (g.fileName != "")
                {
                    System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath((@"~/" + g.fileName)));
                    message.Attachments.Add(attach);
                }

                message.Body = "Problem Description :  " + Prob_Desc +
                               Environment.NewLine
                               + "Reference No         :  " + Ref_No +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Service Request Type :  " + khidmat2 +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Company Name          :  " + Com_Type +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Sent by               :  " + Req_Name +
                               Environment.NewLine
                               + "on this date          :  " + Rec_Date +
                               Environment.NewLine
                               + "Priority Rating is   :  " + Type +
                               Environment.NewLine
                               + "Please Attend to this Problem and Submit Request through Request Application Processing Software as soon as possible" +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Thank you."
                               + Environment.NewLine
                               + "Regards" +
                               Environment.NewLine
                               + Environment.NewLine
                               + "AeroLogica Sdn Bhd  " +
                               Environment.NewLine
                               + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("128.2.11.11");
                smtp.Port = 25;
                try
                {
                    smtp.Send(message);
                    Response.Write("<script>alert('Email Sent Successfully');</script>");
                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Sent Successfully')", true);
                }


                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Couldnt be Sent ')", true);
                }


                System.Net.Mail.MailMessage message2 = new System.Net.Mail.MailMessage();
                message2.To.Add(Req_Email);
                message2.Subject = "Mail from IT Help Desk";
                message2.From    = new System.Net.Mail.MailAddress("*****@*****.**");

                message2.Body = "Dear       :  " + Req_Name
                                + Environment.NewLine
                                + Environment.NewLine
                                + "We acknowledge receipt of your request.Your issue has now been prioritised, and our staff has been assigned to work on it. We will update this service request with further information, as we continue to work on the request."
                                + Environment.NewLine
                                + Environment.NewLine
                                + "Category         :  " + Type +
                                Environment.NewLine
                                + "Reference No     :  " + Ref_No +
                                Environment.NewLine +
                                "Problem Desc      :  " + Prob_Desc
                                + Environment.NewLine
                                + Environment.NewLine
                                + "Thank you."
                                + Environment.NewLine
                                + "Regards"
                                + Environment.NewLine
                                + "AeroLogica Sdn Bhd  "
                                + Environment.NewLine
                                + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";
                System.Net.Mail.SmtpClient smtp2 = new System.Net.Mail.SmtpClient("128.2.11.11");
                smtp2.Port = 25;

                try
                {
                    smtp2.Send(message2);
                    Response.Write("<script>alert('Email sent Successfully');</script>");
                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Sent Successfully')", true);
                }
                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Couldnt be Sent')", true);
                }

                //if (Type == "Urgent")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;
                //    Session["interval"] = 14400000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;

                //}

                //if (Type == "Priority")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;
                //    Session["interval"] = 28800000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;

                //}
                //if (Type == "Normal")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;

                //    Session["interval"] = 129600000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;
                //}
            }


// EMAIL NO 2

            if (((confrim_value == "YES") && (flag == true)) && (CheckBox2.Checked == true))
            {
                int      Ref_No = Int32.Parse(TextBox1.Text);
                DateTime rec_da = System.DateTime.Now;
                if ((TextBox8.Text == "") || (TextBox9.Text == ""))
                {
                    TextBox8.Text = "00";
                    TextBox9.Text = "00";
                }
                string condate  = TextBox6.Text + " " + TextBox8.Text + ":" + TextBox9.Text + ":" + "00";
                string Rec_Date = Convert.ToDateTime(condate).ToString("yyyy/MM/dd HH:mm:ss");

                string   Prob_Desc     = TextBox4.Text;
                string   Type          = DropDownList2.SelectedItem.Text;
                string   Remarks       = DropDownList6.SelectedItem.Value;
                string   Req_Name      = TextBox2.Text;
                string   Com_Type      = DropDownList3.SelectedItem.Text;
                string   Req_Email     = TextBox7.Text;
                string   Req_Status    = DropDownList4.SelectedItem.Text;
                string   Act_Email     = DropDownList7.SelectedItem.Text;
                string   khidmat2      = ddlType.SelectedItem.Text;
                DateTime Escalate_Date = DateTime.Now;

                bl c = new bl();
                try
                {
                    bool stat = c.addsrvreq(Ref_No, Rec_Date, Req_Name, Prob_Desc, Type, Com_Type, Req_Email, Req_Status, Remarks, Act_Email, khidmat2, Escalate_Date);
                }
                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Request Couldnt Be Added Try Again')", true);
                }

                //Response.Cookies[cookname] ["date"]  =Convert.ToString(System.DateTime.Now);
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(Act_Email);
                message.Subject = "Mail from IT Help Desk";
                message.From    = new System.Net.Mail.MailAddress("*****@*****.**");
                if (g.fileName != "")
                {
                    System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath((@"~/" + g.fileName)));
                    message.Attachments.Add(attach);
                }

                message.Body = "Problem Description :  " + Prob_Desc +
                               Environment.NewLine
                               + "Reference No        :  " + Ref_No +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Company Name        :  " + Com_Type +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Sent by             :  " + Req_Name +
                               Environment.NewLine
                               + "on this date        :  " + Rec_Date +
                               Environment.NewLine
                               + "Priority Rating is :  " + Type +
                               Environment.NewLine
                               + "Please Note that this Problem is also CC to         :  " + DropDownList5.Text + "         " + "        " + DropDownList8.Text +
                               Environment.NewLine
                               + "Please Attend to this Problem and Submit Request through Request Application Processing Software as soon as possible" +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Thank you."
                               + Environment.NewLine
                               + "Regards" +
                               Environment.NewLine
                               + Environment.NewLine
                               + "AeroLogica Sdn Bhd  " +
                               Environment.NewLine
                               + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("128.2.11.11");
                smtp.Port = 25;
                try
                {
                    smtp.Send(message);
                    Response.Write("<script>alert('Email sent to Assignee Person');</script>");
                }
                catch
                {
                    Response.Write("<script>alert('Email Couldnt be sent');</script>");
                }


                System.Net.Mail.MailMessage message2 = new System.Net.Mail.MailMessage();
                message2.To.Add(Req_Email);
                message2.Subject = "Mail from IT Help Desk";
                message2.From    = new System.Net.Mail.MailAddress("*****@*****.**");

                message2.Body = "Dear       :  " + Req_Name
                                + Environment.NewLine
                                + Environment.NewLine
                                + "We acknowledge receipt of your request.Your issue has now been prioritised, and our staff has been assigned to work on it. We will update this service request with further information, as we continue to work on the request."
                                + Environment.NewLine
                                + Environment.NewLine
                                + "Category         :  " + Type +
                                Environment.NewLine
                                + "Reference No     :  " + Ref_No +
                                Environment.NewLine +
                                "Problem Desc      :  " + Prob_Desc
                                + Environment.NewLine
                                + Environment.NewLine
                                + "Thank you."
                                + Environment.NewLine
                                + "Regards"
                                + Environment.NewLine
                                + "AeroLogica Sdn Bhd  "
                                + Environment.NewLine
                                + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";
                System.Net.Mail.SmtpClient smtp2 = new System.Net.Mail.SmtpClient("128.2.11.11");
                smtp2.Port = 25;

                try
                {
                    smtp2.Send(message2);
                    Response.Write("<script> alert('Email sent to Requestor');</script>");
                }
                catch
                {
                    Response.Write("<script> alert('Email Couldnt be sent');</script>");
                }


                //if (Type == "Urgent")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;
                //    Session["interval"] = 14400000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;


                //}

                //if (Type == "Priority")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;
                //    Session["interval"] = 28800000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;


                //}
                //if (Type == "Normal")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;

                //    Session["interval"] = 129600000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;


                //}
            }
// EMAIL NO 3
            if (((confrim_value == "YES") && (flag == true)) && (CheckBox3.Checked == true))
            {
                int      Ref_No = Int32.Parse(TextBox1.Text);
                DateTime rec_da = System.DateTime.Now;
                if ((TextBox8.Text == "") || (TextBox9.Text == ""))
                {
                    TextBox8.Text = "00";
                    TextBox9.Text = "00";
                }
                string condate  = TextBox6.Text + " " + TextBox8.Text + ":" + TextBox9.Text + ":" + "00";
                string Rec_Date = Convert.ToDateTime(condate).ToString("yyyy/MM/dd HH:mm:ss");

                string   Prob_Desc     = TextBox4.Text;
                string   Type          = DropDownList2.SelectedItem.Text;
                string   Remarks       = DropDownList6.SelectedItem.Value;
                string   Req_Name      = TextBox2.Text;
                string   Com_Type      = DropDownList3.SelectedItem.Text;
                string   Req_Email     = TextBox7.Text;
                string   Req_Status    = DropDownList4.SelectedItem.Text;
                string   Act_Email     = DropDownList8.SelectedItem.Text;
                string   khidmat2      = ddlType.SelectedItem.Text;
                DateTime Escalate_Date = DateTime.Now;


                bl c = new bl();
                try
                {
                    HttpContext.Current.Server.ScriptTimeout = 900000;
                    bool stat = c.addsrvreq(Ref_No, Rec_Date, Req_Name, Prob_Desc, Type, Com_Type, Req_Email, Req_Status, Remarks, Act_Email, khidmat2, Escalate_Date);
                    Response.Write("<script>alert('Request Added Successfully');</script>");
                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Request Added Successfully')", true);
                }
                catch
                {
                    Response.Write("<script>alert('Request NOT Added TRY AGAIN');</script>");
                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Request Not Added Try Again')", true);
                }

                //Response.Cookies[cookname] ["date"]  =Convert.ToString(System.DateTime.Now);
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(Act_Email);
                message.Subject = "Mail from IT Help Desk";
                message.From    = new System.Net.Mail.MailAddress("*****@*****.**");
                if (g.fileName != "")
                {
                    System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath((@"~/" + g.fileName)));
                    message.Attachments.Add(attach);
                }

                message.Body = "Problem Description :  " + Prob_Desc +
                               Environment.NewLine
                               + "Reference No        :  " + Ref_No +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Company Name        :  " + Com_Type +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Sent by             :  " + Req_Name +
                               Environment.NewLine
                               + "on this date        :  " + Rec_Date +
                               Environment.NewLine
                               + "Priority Rating is :  " + Type +
                               Environment.NewLine
                               + "Please Attend to this Problem and Submit Request through Request Application Processing Software as soon as possible" +
                               Environment.NewLine
                               + "Please Note that this Problem is also Forwarded to  :  " + DropDownList5.Text + " and  " + DropDownList7.Text +
                               Environment.NewLine
                               + Environment.NewLine
                               + "Thank you."
                               + Environment.NewLine
                               + "Regards" +
                               Environment.NewLine
                               + Environment.NewLine
                               + "AeroLogica Sdn Bhd  " +
                               Environment.NewLine
                               + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("128.2.11.11");
                smtp.Port = 25;
                try
                {
                    smtp.Send(message);
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Sent To Problem Solver')", true);
                }
                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Couldnt be Sent Try Again')", true);
                }


                System.Net.Mail.MailMessage message2 = new System.Net.Mail.MailMessage();
                message2.To.Add(Req_Email);
                message2.Subject = "Mail from IT Help Desk";
                message2.From    = new System.Net.Mail.MailAddress("*****@*****.**");

                message2.Body = "Dear       :  " + Req_Name
                                + Environment.NewLine
                                + Environment.NewLine
                                + "We acknowledge receipt of your request.Your issue has now been prioritised, and our staff has been assigned to work on it. We will update this service request with further information, as we continue to work on the request."
                                + Environment.NewLine
                                + Environment.NewLine
                                + "Category         :  " + Type +
                                Environment.NewLine
                                + "Reference No     :  " + Ref_No +
                                Environment.NewLine +
                                "Problem Desc      :  " + Prob_Desc
                                + Environment.NewLine
                                + Environment.NewLine
                                + "Thank you."
                                + Environment.NewLine
                                + "Regards"
                                + Environment.NewLine
                                + "AeroLogica Sdn Bhd  "
                                + Environment.NewLine
                                + "Tel No: 03 -7846 5112    Ext No: 273 / 314 /317  ";
                System.Net.Mail.SmtpClient smtp2 = new System.Net.Mail.SmtpClient("128.2.11.11");
                smtp2.Port = 25;



                try
                {
                    smtp2.Send(message2);
                    Response.Write("<script>alert('Email sent to Requestor');</script>");
                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Sent To Requestor')", true);
                }
                catch
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript", "alert('Email Coulnt Be Sent Try Again')", true);
                }


                //if (Type == "Urgent")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;
                //    Session["interval"] = 14400000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;


                //}

                //if (Type == "Priority")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;
                //    Session["interval"] = 28800000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;


                //}
                //if (Type == "Normal")
                //{
                //    DateTime valdate = Convert.ToDateTime(Request.Cookies[cookname].Value);
                //    Session["valdate"] = valdate;

                //    Session["interval"] = 129600000;
                //    Session["Act_Email"] = Act_Email;
                //    Session["Ref_No"] = Ref_No;
                //    Session["Prob_Desc"] = Prob_Desc;
                //    Session["Req_Name"] = Req_Name;


                //}
            }
            Server.Transfer("AddReq.aspx");
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedIndex != 0)
        {
            if (DropDownList2.SelectedIndex != 0)
            {
                //DataSet ds3 = new DataSet();
                //string ui = "select t_id from tiffin_with_sweet order by t_id DESC";
                //ds3 = dc.getdata(ui);

                //if (ds3.Tables[0].Rows.Count == 0)
                //{
                //    tid = "TWS1";
                //}
                //else
                //{
                //    String s = ds3.Tables[0].Rows[0][0].ToString();

                //    string t = s.Substring(3, s.Length - 3);
                //    int n = Convert.ToInt32(t);
                //    n = n + 1;


                //    tid = "TWS" + n.ToString();
                //}

                string ext = System.IO.Path.GetExtension(FileUpload1.FileName);

                if (ext == ".jpg" || ext == ".png" || ext == ".jpeg" || ext == ".gif" || ext == ".GIF" || ext == ".PNG" || ext == ".JPEG" || ext == ".JPG")
                {
                    FileUpload1.SaveAs(Server.MapPath("~//admin//tiffin_with_sweet_image//" + FileUpload1.FileName));
                    string path = "~//admin//tiffin_with_sweet_image//" + FileUpload1.FileName;


                    try
                    {
                        if (Std_chk.Checked == true)
                        {
                            std = "1";
                        }
                        else
                        {
                            std = "0";
                        }

                        if (avg_chk.Checked == true)
                        {
                            avg = "1";
                        }
                        else
                        {
                            avg = "0";
                        }

                        if (poor_chk.Checked == true)
                        {
                            poor = "1";
                        }
                        else
                        {
                            poor = "0";
                        }

                        if (Rmd_yes_rb.Checked == true)
                        {
                            string q = "insert into tiffin_with_sweet values('" + TextBox7.Text + "','" + DropDownList1.Text + "','" + DropDownList2.Text + "','" + Label2.Text + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox8.Text + "','" + TextBox6.Text + "','" + std + "','" + avg + "','" + poor + "','" + TextBox9.Text + "','1','" + path + "','Order Now'," + IsAppHomeChk.Checked + ")";
                            dc.setdata(q);
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + TextBox7.Text + " Tiffin With Sweet Added'');", true);

                            TextBox1.Text               = "";
                            TextBox2.Text               = "";
                            TextBox3.Text               = "";
                            TextBox4.Text               = "";
                            TextBox5.Text               = "";
                            TextBox6.Text               = "";
                            TextBox7.Text               = "";
                            TextBox8.Text               = "";
                            TextBox9.Text               = "";
                            Std_chk.Checked             = false;
                            avg_chk.Checked             = false;
                            poor_chk.Checked            = false;
                            IsAppHomeChk.Checked        = false;
                            DropDownList1.SelectedIndex = 0;
                            DropDownList2.Items.Clear();
                            Label2.Text = "";
                        }
                        if (Rmd_no_rb.Checked == true)
                        {
                            string q = "insert into tiffin_with_sweet values('" + TextBox7.Text + "','" + DropDownList1.Text + "','" + DropDownList2.Text + "','" + Label2.Text + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox8.Text + "','" + TextBox6.Text + "','" + std + "','" + avg + "','" + poor + "','" + TextBox9.Text + "','0','" + path + "','Order Now'," + IsAppHomeChk.Checked + ")";
                            dc.setdata(q);
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + TextBox7.Text + " Tiffin With Sweet Added'');", true);

                            TextBox1.Text               = "";
                            TextBox2.Text               = "";
                            TextBox3.Text               = "";
                            TextBox4.Text               = "";
                            TextBox5.Text               = "";
                            TextBox6.Text               = "";
                            TextBox7.Text               = "";
                            TextBox8.Text               = "";
                            TextBox9.Text               = "";
                            Std_chk.Checked             = false;
                            avg_chk.Checked             = false;
                            poor_chk.Checked            = false;
                            IsAppHomeChk.Checked        = false;
                            DropDownList1.SelectedIndex = 0;
                            DropDownList2.Items.Clear();
                            Label2.Text = "";
                        }
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('This Tiffin Id Already Exist.');", true);
                        TextBox7.Text = "";
                        TextBox7.Focus();
                    }

                    //String j = Label1.Text;
                    //string k = j.Substring(3, j.Length - 3);
                    //int l = Convert.ToInt32(k);
                    //l = l + 1;
                    //string jy = "TWS" + l.ToString();
                    //Label1.Text = jy;
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Please select Image Only');", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Please select provider');", true);
                //Response.Write("<script>alert('Please select provider')</script>");
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Please Select City');", true);
            //Response.Write("<script>alert('Please select city')</script>");
        }
    }
Exemplo n.º 23
0
        private void Listen()
        {
            EndPoint ServerEP = (EndPoint)T.RemoteEndPoint;

            byte[] B     = new byte[1023];
            int    inLen = 0; //接收的位元組數目

            while (true)
            {
                try
                {
                    inLen = T.ReceiveFrom(B, ref ServerEP);//收聽資訊並取得位元組數
                }
                catch (Exception)
                {
                    T.Close();
                    listBox1.Items.Clear();                                                             //清除線上名單
                    MessageBox.Show("伺服器斷線了!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information); //顯示斷線
                    TextBox5.AppendText("(系統) : 伺服器已斷線了! \r\n");
                    button1.Enabled = true;                                                             //連線按鍵恢復可用
                    Th.Abort();                                                                         //刪除執行緒
                }

                string Msg = Encoding.Default.GetString(B, 0, inLen); //解讀完整訊息
                string St  = Msg.Substring(0, 1);                     //取出命令碼 (第一個字)
                string Str = Msg.Substring(1);                        //取出命令碼之後的訊息
                switch (St)                                           //依命令碼執行功能
                {
                case "L":                                             //接收線上名單
                    listBox1.Items.Clear();                           //清除名單
                    string[] M = Str.Split(',');                      //拆解名單成陣列
                    player = M;
                    for (int i = 0; i < M.Length; i++)
                    {
                        listBox1.Items.Add(M[i]);                                    //逐一加入名單
                    }
                    break;

                case "S":
                    Count--;
                    TextBox9.AppendText(Str + "\r\n");
                    TextBox9.AppendText(DMaster + ": +10" + "\r\n");
                    if (DMaster == User)
                    {
                        user_scro += 10;
                    }
                    break;

                case "D": TextBox5.AppendText("(公開)" + Str + "\r\n"); break;   //聊天室

                case "3": TextBox5.AppendText("(私密)" + Str + "\r\n"); break;   //私密訊息

                case "M": TextBox7.AppendText(Str + "\r\n"); break;

                case "P": PointShape(Str); break;

                case "A": Ans = Str; break;

                case "C": D.Shapes.Clear(); break;

                case "G": Game(); break;

                case "R": metroButton3.Show(); break;
                }
            }
        }