private void GetSupportNoteInForm() { string start_time = (this.IS_BREAK == "Y" ? this.dtBreakStart.Text : this.dtStartTime.Text); string end_time = (this.IS_BREAK == "Y" ? this.dtBreakEnd.Text : this.dtEndTime.Text); this.note = (this.note == null ? new SupportNote() { id = -1 } : this.note); //SupportNote note = new SupportNote() //{ this.note.date = this.dtWorkDate.Value.ToMysqlDate(); this.note.users_name = ((Users)((ComboboxItem)this.cbUser.SelectedItem).Tag).username; this.note.start_time = start_time; this.note.end_time = end_time; this.note.duration = TimeSpan.FromSeconds(TimeSpan.Parse(end_time).TotalSeconds - TimeSpan.Parse(start_time).TotalSeconds).ToString(); this.note.sernum = (this.IS_BREAK == "N" ? this.txtSernum.Texts : this.txtSernum2.Texts); this.note.contact = this.txtContact.Texts; this.note.problem = this.GetProblemFormattedString(); this.note.remark = (this.IS_BREAK == "N" ? this.txtRemark.Text : this.txtRemark2.Text); this.note.is_break = this.IS_BREAK; this.note.reason = this.GetReasonFormattedString(); this.note.file_path = ""; this.note.rec_by = this.stat_windows.main_form.G.loged_in_user_name; //}; //return this.note; }
public SupportNoteDialog(SupportStatWindow stat_windows, bool is_break, SupportNote editing_note) : this() { this.mode = MODE.EDIT; this.stat_windows = stat_windows; this.IS_BREAK = (is_break ? "Y" : "N"); this.note = editing_note; }
public TrainerNoteDialog(MainForm main_form, Users user, DateTime date, SupportNote support_note = null) { InitializeComponent(); this.main_form = main_form; this.user = user; this.date = date; this.support_note = support_note; }
private void SaveToDB(SupportNote note) { bool save_success = false; string err_msg = string.Empty; string json_data = "{\"id\":" + note.id + ","; json_data += "\"sernum\":\"" + (note.sernum.Replace("-", "").Replace(" ", "").Length > 0 ? note.sernum.cleanString() : "") + "\","; json_data += "\"date\":\"" + note.date + "\","; json_data += "\"contact\":\"" + note.contact.cleanString() + "\","; json_data += "\"start_time\":\"" + note.start_time + "\","; json_data += "\"end_time\":\"" + note.end_time + "\","; json_data += "\"duration\":\"" + note.duration.Substring(0, 8) + "\","; json_data += "\"problem\":\"" + note.problem.cleanString() + "\","; json_data += "\"remark\":\"" + note.remark.cleanString() + "\","; json_data += "\"also_f8\":\"" + "N" + "\","; json_data += "\"probcod\":\"" + "" + "\","; json_data += "\"is_break\":\"" + this.IS_BREAK + "\","; json_data += "\"reason\":\"" + note.reason.cleanString() + "\","; json_data += "\"users_name\":\"" + note.users_name + "\","; json_data += "\"rec_by\":\"" + note.rec_by + "\"}"; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { CRUDResult post; if (note.id < 0) // create { post = (this.IS_BREAK == "N" ? ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/create", json_data) : ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/create_break", json_data)); } else // update { post = (this.IS_BREAK == "N" ? ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/update", json_data) : ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/update_break", json_data)); } ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { save_success = true; } else { err_msg = sr.message; save_success = false; } }; worker.RunWorkerCompleted += delegate { if (save_success) { this.DialogResult = DialogResult.OK; this.Close(); } else { if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry) { this.SaveToDB(note); return; } else { this.DialogResult = DialogResult.Cancel; this.Close(); } } }; worker.RunWorkerAsync(); }