public void setFrom(UserSupport_Model data, Support_Controller controller) { IsSetForm = true; mData = data; mController = controller; setData(); }
private void Dv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex >= 0) { try { long id = (long)dv.Rows[e.RowIndex].Cells["ID"].Value; selectedItem = result.Where(s => s.id == id).FirstOrDefault(); if (selectedItem != null) { rtb_message.Text = selectedItem.message; } if (selectedItem.isreplied) { btn_reviewReply.Visible = true; btn_Reply.Visible = false; } else { btn_reviewReply.Visible = false; btn_Reply.Visible = true; } } catch { } } }
private void Btn_Reply_Click(object sender, EventArgs e) { if (selectedItem != null) { using (ReplySupportForm form = new ReplySupportForm()) { form.setFrom(selectedItem, controller); form.ShowDialog(); } Btn_Search_Click(null, null); selectedItem = result.Where(s => s.id == selectedItem.id).FirstOrDefault(); if (selectedItem != null) { rtb_message.Text = selectedItem.message; if (selectedItem.isreplied) { btn_reviewReply.Visible = true; btn_Reply.Visible = false; } else { btn_reviewReply.Visible = false; btn_Reply.Visible = true; } } else { rtb_message.Text = string.Empty; btn_reviewReply.Visible = false; btn_Reply.Visible = false; } } }
public bool SearchUser(ref List <UserSupport_Model> lstResult, bool?isreplied = null) { bool result = false; try { string condition = string.Empty; if (isreplied != null) { condition += "isreplied = " + isreplied.ToString() + " "; } DataTable dt; if ((dt = DBHandler.selectDataBase(ref conn, "`order_user_support`", "`id`, `name`, `mail`, `phonenumber`, `message`, `isreplied`, `repliedmessage`, `repliedsubject`", condition)) != null) { lstResult = new List <UserSupport_Model>(); for (int i = 0; i < dt.Rows.Count; i++) { UserSupport_Model item = new UserSupport_Model() { id = (long)dt.Rows[i]["id"], name = (string)dt.Rows[i]["name"], mail = (string)dt.Rows[i]["mail"], phonenumber = (string)dt.Rows[i]["phonenumber"], message = (string)dt.Rows[i]["message"], isreplied = (bool)dt.Rows[i]["isreplied"], repliedsubject = (string)dt.Rows[i]["repliedsubject"], repliedmessage = (string)dt.Rows[i]["repliedmessage"] }; lstResult.Add(item); } result = true; } } catch (Exception ex) { LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message); } return(result); }
private void Dv_SelectionChanged(object sender, EventArgs e) { if (dv.SelectedRows.Count == 1) { long id = (long)dv.SelectedRows[0].Cells["ID"].Value; selectedItem = result.Where(s => s.id == id).FirstOrDefault(); if (selectedItem != null) { rtb_message.Text = selectedItem.message; } if (selectedItem.isreplied) { btn_reviewReply.Visible = true; btn_Reply.Visible = false; } else { btn_reviewReply.Visible = false; btn_Reply.Visible = true; } } }
/// <summary> /// /// </summary> /// <param name="mData"></param> /// <returns>-1: false; 0: success; 1: Can't connect DB; 2: Can't sendmail</returns> public int ReplySupportRequest(UserSupport_Model mData) { int result = -1; try { //Ghi DB voi thong tin username if (DBHandler.updateDataBase(ref conn, "`order_user_support`", "`isreplied`=" + true.ToString() + ",`repliedsubject`='" + mData.repliedsubject + "',`repliedmessage`='" + mData.repliedmessage + "'", "`id`= " + mData.id)) { //Gui mai : SMPTGMail mail = new SMPTGMail(AppConfig.UserGmailSupport, AppConfig.PasswordGmailSupport); bool sendmailSuccess = false; for (int i = 0; i < 5; i++) { if (mail.SendMailOnlyOne(mData.mail, mData.repliedsubject, mData.repliedmessage.Replace("\n", "<br/>"))) { sendmailSuccess = true; break; } } result = (sendmailSuccess) ? 0 : 2; if (result == 2) { DBHandler.updateDataBase(ref conn, "`order_user_support`", "`isreplied`=" + false.ToString() + ",`repliedsubject`='',`repliedmessage`=''", "`id`= " + mData.id); } } else { result = 1; } } catch (Exception ex) { LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message); } return(result); }
private void btn_send_Click(object sender, EventArgs e) { if (IsSetForm) { UserSupport_Model item = new UserSupport_Model() { id = mData.id, mail = mData.mail, message = mData.message, name = mData.name, phonenumber = mData.phonenumber, isreplied = true, repliedsubject = tb_subject.Text, repliedmessage = rtb_content.Text }; int result = mController.ReplySupportRequest(item); if (result == -1) { Functions.ShowMessgeError("Lỗi không xác định"); } else if (result == 0) { Functions.ShowMessgeInfo("Thành công"); mData = item; tb_subject.ReadOnly = true; rtb_content.ReadOnly = true; btn_send.Visible = false; } else if (result == 1) { Functions.ShowMessgeError("Không có kết nối Database"); } else if (result == 2) { Functions.ShowMessgeError("Không thể send mail"); } } }