protected void Button_add_click(object sender, EventArgs e) { WarrantyNotify wn = new WarrantyNotify(); wn.DeviceID = DropDownList_DeviceID.SelectedValue; wn.FaultModel = this.DropDownList_FaultModel_add.Text; wn.FaultDescribe = this.TextBox_FaultDescribe_add.Text; wn.RepeatNotify = this.TextBox_RepeatNotify_add.Text; wn.WarrantyCompany = this.DropDownList_WarrantyCompany_add.SelectedItem.ToString(); wn.WarrantyContract = int.Parse(this.DropDownList_WarrantyContract_add.SelectedValue); wn.NotifyDate = Convert.ToDateTime(this.TextBox_NotifyDate_add.Text); wn.NotifyConfirm = false; if (this.DropDownList_ContractCombineNum.SelectedIndex > 0) { wn.ContractCombineNum = int.Parse(this.DropDownList_ContractCombineNum.SelectedItem.ToString()); } wn.Status = "維修中"; switch (this.DropDownList_RepairDateOption_add.SelectedIndex) { case 0: //修復日期選項 ShowPageMsg("請點選修復日期選項!"); return; //break; case 1: wn.RepairDateOption = 1; break; case 2: wn.RepairDateOption = 2; break; case 3: wn.RepairDateOption = 3; wn.RepairDeadline = Convert.ToDateTime(this.TextBox_RepairDeadline_add.Text); break; } try { wn.Add(); ShowPageMsg("新增保固單成功!"); UpdateServerData(); } catch (Exception ee) { ShowPageMsg("新增保固單失敗!"); } }
protected void Button_add_click(object sender, EventArgs e) { //通報者名稱 string reportid = Session["UserID"].ToString(); if (TextBox_FaultDescribe_add.Text.Length == 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('請輸入故障描述!');", true); return; } if (hidden_Action.Value == "edit") { SQLDB _operator = new SQLDB(); DataSet ds_edit = _operator.Select("CaseID = '" + hidden_Caseid.Value + "'", "", "WarrantyNotify"); DataRow dr = ds_edit.Tables[0].Rows[0]; dr["FaultModel"] = this.DropDownList_FaultModel_add.Text; dr["FaultDescribe"] = this.TextBox_FaultDescribe_add.Text; dr["RepeatNotify"] = this.TextBox_RepeatNotify_add.Text; dr["WarrantyCompany"] = this.DropDownList_WarrantyCompany_add.SelectedItem.ToString(); dr["WarrantyContract"] = int.Parse(this.DropDownList_WarrantyContract_add.SelectedValue); dr["NotifyDate"] = Convert.ToDateTime(this.TextBox_NotifyDate_add.Text); if (this.DropDownList_ContractCombineNum.SelectedIndex > 0) { dr["ContractCombineNum"] = int.Parse(this.DropDownList_ContractCombineNum.SelectedItem.ToString()); } switch (this.DropDownList_RepairDateOption_add.SelectedIndex) { case 0: //修復日期選項 ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('請點選修復日期選項!');", true); return; //break; case 1: dr["RepairDateOption"] = 1; break; case 2: dr["RepairDateOption"] = 2; break; case 3: dr["RepairDateOption"] = 3; dr["RepairDeadline"] = Convert.ToDateTime(this.TextBox_RepairDeadline_add.Text); break; } DataSet DSChange = ds_edit.GetChanges(DataRowState.Modified); if (_operator.Update(DSChange)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('修改成功');", true); UpdateServerData(); } } else { WarrantyNotify wn = new WarrantyNotify(); wn.DeviceID = this.TextBox_DeviceID_add.Text; wn.FaultModel = this.DropDownList_FaultModel_add.Text; wn.FaultDescribe = this.TextBox_FaultDescribe_add.Text; wn.RepeatNotify = this.TextBox_RepeatNotify_add.Text; wn.WarrantyCompany = this.DropDownList_WarrantyCompany_add.SelectedItem.ToString(); if (this.DropDownList_WarrantyContract_add.SelectedIndex > 0) { wn.WarrantyContract = int.Parse(this.DropDownList_WarrantyContract_add.SelectedValue); } wn.NotifyDate = Convert.ToDateTime(this.TextBox_NotifyDate_add.Text); wn.NotifyConfirm = false; if (this.DropDownList_ContractCombineNum.SelectedIndex > 0) { wn.ContractCombineNum = int.Parse(this.DropDownList_ContractCombineNum.SelectedItem.ToString()); } wn.Status = "維修中"; switch (this.DropDownList_RepairDateOption_add.SelectedIndex) { case 0: //修復日期選項 ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('請點選修復日期選項!');", true); return; //break; case 1: wn.RepairDateOption = 1; break; case 2: wn.RepairDateOption = 2; break; case 3: wn.RepairDateOption = 3; wn.RepairDeadline = Convert.ToDateTime(this.TextBox_RepairDeadline_add.Text); break; } wn.Add(); ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('新增成功');", true); UpdateServerData(); } if (chk_isSendMail.Checked) { try { //傳送通知email給廠商 string[] mailaddress = new string[1]; SQLDB _operateor = new SQLDB(); DataSet ds = new DataSet(); ds = _operateor.Select("CompanyID ='" + DropDownList_WarrantyCompany_add.SelectedValue + "'", "", "Company"); if (ds.Tables[0].Rows.Count > 0) { mailaddress[0] = ds.Tables[0].Rows[0]["Email"].ToString(); } Email notifyemail = new Email(); //通報內容 //string body = ""; string first_td = " <td width='150' align='center' style='background-color: #c4ffde;' > "; string second_td = " <td align='center' style='background-color: #ffff9d;' > "; StringBuilder body = new StringBuilder(); body.Append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"); body.Append("<HTML><HEAD><META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"); body.Append("</HEAD><BODY>"); body.Append(" <table width='80%' border='1' align='center' cellpadding='0' cellspacing='0'>"); body.Append(" <tr> "); body.Append(" <td colspan='2' align='center' style='background-color: #ffcc33;'><h3> " + "新北市停車管理系統報修服務單" + "</h3> </td> "); body.Append(" </tr> "); body.Append(" <tr> "); body.Append(first_td + "設備編號" + " </td> "); body.Append(second_td + TextBox_DeviceID_add.Text + " </td> "); body.Append(" </td> "); body.Append(" </tr> "); body.Append(" <tr> "); body.Append(first_td + "通報者" + " </td> "); body.Append(second_td + reportid + " </td> "); body.Append(" </td> "); body.Append(" </tr> "); body.Append(" <tr> "); body.Append(first_td + "通報時間" + " </td> "); body.Append(second_td + TextBox_NotifyDate_add.Text + " </td> "); body.Append(" </td> "); body.Append(" </tr> "); body.Append(" <tr> "); body.Append(first_td + "指定修復日期" + " </td> "); body.Append(second_td + TextBox_RepairDeadline_add.Text + " </td> "); body.Append(" </td> "); body.Append(" </tr> "); body.Append(" <tr> "); body.Append(first_td + "損壞原因描述" + " </td> "); body.Append(second_td + TextBox_FaultDescribe_add.Text + " </td> "); body.Append(" </td> "); body.Append(" </tr> "); body.Append(" <tr> "); body.Append(" <td colspan='2' align='center' style='background-color: #cccc99;'> " + "本郵件由發信系統主動發出,請勿直接回覆,如有任何問題或意見,請撥電話至停管中心" + " </td> "); body.Append(" </tr> "); body.Append(" </table> "); body.Append("</BODY></HTML>"); if (notifyemail.toSend("新北市停車管理系統報修服務單", mailaddress, body.ToString())) { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('郵件寄送成功');", true); } } catch (Exception ee) { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "window.alert('新增保固單失敗!');", true); } } }