コード例 #1
0
ファイル: ModReq.aspx.cs プロジェクト: cayrosuke/itservice
        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            HttpContext.Current.Server.ScriptTimeout = 900000;
            string val = Request.Form["confirm_value"];
            //string val1=string.Empty;
            //string jsScript = "";
            //jsScript += "var answer=confirm(\'Action Already Taken do you want to modify?\');\n";
            //jsScript += "if(answer){\n";
            //jsScript += "'" + val1 + "'='YES'}\n";

            bl mod = new bl();

            int refno = int.Parse(DropDownList1.SelectedItem.Text);

            MySqlDataReader dd = null;

            dd = mod.modreq(refno);

            if (val == "YES")
            {
                if (acttak != null)
                {
                }
                bl  upd    = new bl();
                int Ref_No = int.Parse(DropDownList1.SelectedItem.Text);

                string Req_Name  = TextB.Text;
                string Com_Type  = DropDownList3.SelectedItem.Text;
                string Prob_Desc = TextBox5.Text;
                string Rec_Date  = null;
                //string Rec_Date = Convert.ToDateTime(TextBox6.Text).ToString("yyyy/MM/dd hh:mm:ss");


                if ((TextBox12.Text == "") || (TextBox13.Text == ""))
                {
                    string Rec_Date1 = Convert.ToDateTime(TextBox6.Text).ToShortDateString() + " " + "00" + ":" + "00";
                    Rec_Date = Convert.ToDateTime(Rec_Date1).ToString("yyyy/MM/dd hh:mm:ss");
                }
                else
                {
                    string Rec_Date1 = Convert.ToDateTime(TextBox6.Text).ToShortDateString() + " " + TextBox12.Text + ":" + TextBox13.Text;
                    Rec_Date = Convert.ToDateTime(Rec_Date1).ToString("yyyy/MM/dd hh:mm:ss");
                }

                string Req_Email  = TextBox9.Text;
                string Action     = acttak.Text;
                string Action_By  = DropDownList2.SelectedItem.Text;
                string Remarks    = DropDownList5.SelectedItem.Value;                                  //select manual for REMARKS and save data in "tbl_srvmast"
                string Com_Date   = Convert.ToDateTime(TextBox7.Text).ToString("yyyy/MM/dd hh:mm:ss"); //select manual by user and save data in "tbl_srvmast"
                string Req_Status = DropDownList4.SelectedItem.Text;
                float  Req_Times  = Convert.ToInt32(TextBox11.Text);
                string servType   = ddlType.SelectedItem.Text;

                DateTime Com_Dates = DateTime.Now; //complete date save in tbl_srvmast1 only
                DateTime escalate;

                //to calculate escalate time
                if (dd["Escalate_Date"].ToString() == "".Trim())
                {
                    escalate       = DateTime.Now;
                    TextBox14.Text = escalate.ToString();
                }
                else
                {
                    escalate = Convert.ToDateTime(dd["Escalate_Date"]);
                }

                DateTime date_now = DateTime.Now;

                //Automation REMARK for bos only and save in TABLE "tbl_srvmast1"
                string Type   = dd.GetString("Type");
                string Remark = "";
                double d      = double.Parse(TextBox11.Text); //time comparison

                if (Type == "Normal")
                {
                    if ((d >= 0.00) && (d <= 38.00))
                    {
                        Remark = "Meet Hours";
                    }
                    else
                    {
                        Remark = "Not Meet Hours";
                    }
                    //TextBox7.Text = Type + "" + Remarks;
                }

                if (Type == "Priority")
                {
                    if ((d >= 0.00) && (d <= 8.00))
                    {
                        Remark = "Meet Hours";
                    }
                    else
                    {
                        Remark = "Not Meet Hours";
                    }
                    //TextBox7.Text = Type + "" + Remarks;
                }
                if (Type == "Urgent")
                {
                    if ((d >= 0.00) && (d <= 4.00))
                    {
                        Remark = "Meet Hours";
                    }
                    else
                    {
                        Remark = "Not Meet Hours";
                    }
                    //TextBox7.Text = Type + "" + Remarks;
                }
                //end calculation
                bool stat = false;
                try
                {
                    HttpContext.Current.Server.ScriptTimeout = 9000;
                    Server.ScriptTimeout = 900;

                    stat = upd.updreq(Ref_No, Req_Name, Com_Type, Prob_Desc, Rec_Date, Req_Email, Req_Status, Action, Action_By, Com_Date, Remarks, Req_Times, servType);  //table for audit reference
                    stat = upd.updreq1(Ref_No, Req_Name, Com_Type, Prob_Desc, Rec_Date, Req_Email, Req_Status, Action, Action_By, Com_Dates, Remark, Req_Times, servType); //table for BUSWANI reference


                    if (stat)
                    {
                        Response.Write("<script>alert('UPDATED SUCCESSFULLY');</script>");
                        //ScriptManager.RegisterClientScriptBlock(this.Page, typeof(Page), "myscript", "alert('MODIFIED SUCCESSFULLY')", true);
                        string formattedcomdate             = Convert.ToDateTime(Com_Date).ToShortDateString();
                        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                        message.To.Add(Req_Email);
                        message.Subject = "Mail from Aerologica Service Team";
                        message.From    = new System.Net.Mail.MailAddress("*****@*****.**");
                        message.Body    = "Respected   :     " + Req_Name +
                                          Environment.NewLine
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + "Type of Service Request:   " + servType
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + "Your Problem Description:  " + Prob_Desc + "   has now been solved."
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + "Action Description : " + Action
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + "Action Taken By Aerologica IT Personnel: " + Action_By
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + "on this date : " + formattedcomdate
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + Environment.NewLine
                                          + "Thank you."
                                          + 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
                        {
                            Response.Write("<script>alert('Email sent to Requestor Successfully');</script>");
                            //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript1", "alert('Email Sent Successfully')", true);
                            smtp.Send(message);
                        }
                        catch
                        {
                            Response.Write("<script>alert('Email COULDNT BE sent to Requestor');</script>");
                            //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "myscript2", "alert('Email Couldnt be Sent')", true);
                        }
                    }
                }
                catch
                {
                    Response.Write("<script>alert('COULDNT UPDATE THE RECORD TRY AGAIN');</script>");
                    stat = false;
                }
            }
        }