private void IstabAddEditForm_Load(object sender, EventArgs e) { if (this.mode == FORM_MODE.ADD) { this.Text = "Add data : " + Istab.getTabtypTitle(this.tabtyp); this.txtTypcod.Focus(); } else { this.Text = "Edit data : " + Istab.getTabtypTitle(this.tabtyp); this.txtTypcod.Enabled = false; this.txtAbbreviate_th.Focus(); CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "istab/get_by_id&id=" + this.istab.id); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { if (sr.istab != null) { this.istab = sr.istab.First <Istab>(); this.txtTypcod.Text = this.istab.typcod; this.txtAbbreviate_en.Text = this.istab.abbreviate_en; this.txtAbbreviate_th.Text = this.istab.abbreviate_th; this.txtTypdes_en.Text = this.istab.typdes_en; this.txtTypdes_th.Text = this.istab.typdes_th; } } } }
private void LoadDependenciesData() { #region Users list CRUDResult get_user = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_all"); ServerResult sr_user = JsonConvert.DeserializeObject <ServerResult>(get_user.data); if (sr_user.result == ServerResult.SERVER_RESULT_SUCCESS) { this.list_users = sr_user.users; } #endregion Users list #region Leave reason CRUDResult get_leave_cause = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "istab/get_leave_cause"); ServerResult sr_leave_cause = JsonConvert.DeserializeObject <ServerResult>(get_leave_cause.data); if (sr_leave_cause.result == ServerResult.SERVER_RESULT_SUCCESS) { this.list_reason = sr_leave_cause.istab; } #endregion Leave reason #region Medical Certificate this.list_medcert.Add(new ComboboxItem("N/A (ไม่ระบุ)", 9, "X")); this.list_medcert.Add(new ComboboxItem("ไม่มีใบรับรองแพทย์", 0, "N")); this.list_medcert.Add(new ComboboxItem("มีใบรับรองแพทย์", 1, "Y")); #endregion Medical Certificate #region Status this.list_status.Add(new ComboboxItem("WAIT", (int)CustomDateEvent.EVENT_STATUS.WAIT_FOR_CONFIRM, "WAIT")); this.list_status.Add(new ComboboxItem("CONFIRMED", (int)CustomDateEvent.EVENT_STATUS.CONFIRMED, "CONFIRMED")); this.list_status.Add(new ComboboxItem("CANCELED", (int)CustomDateEvent.EVENT_STATUS.CANCELED, "CANCELED")); #endregion Status }
private void workerSubmit_Dowork(object sender, DoWorkEventArgs e) { string json_data = "{\"id\":" + this.serial.id.ToString() + ","; json_data += "\"lost_sernum\":\"" + this.mskLostSernum.Text.cleanString() + "\","; json_data += "\"new_sernum\":\"" + this.mskNewSernum.Text.cleanString() + "\","; json_data += "\"version\":\"" + this.txtVersion.Text.cleanString() + "\","; json_data += "\"is_newrwt\":\"" + this.chkNewRwt.CheckState.ToYesOrNoString() + "\","; json_data += "\"is_newrwt_job\":\"" + this.chkNewRwtJob.CheckState.ToYesOrNoString() + "\","; json_data += "\"is_cdtraining\":\"" + this.chkCDTraining.CheckState.ToYesOrNoString() + "\","; json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/lost_renew", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); Console.WriteLine(sr.message); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { this.DialogResult = DialogResult.OK; this.submit_result = true; } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); this.submit_result = false; } }
private void btnOK_Click(object sender, EventArgs e) { List <Users> list_selected_trainer = (from r in this.dgvSelected.Rows.Cast <DataGridViewRow>() select(Users) r.Tag).ToList <Users>(); StringBuilder trainer_id = new StringBuilder(); int cnt = 0; foreach (Users u in list_selected_trainer) { cnt++; trainer_id.Append((cnt == 1 ? u.id.ToString() : "," + u.id.ToString())); } string json_data = "{\"date\":\"" + this.date_event.Date.ToMysqlDate() + "\","; json_data += "\"trainer_id\":\"" + trainer_id.ToString() + "\","; json_data += "\"rec_by\":\"" + this.date_event.G.loged_in_user_name + "\"}"; Console.WriteLine(" >>> " + json_data); CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "trainingcalendar/change", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } }
public static bool CreateHolidayNote(NoteCalendar note) { string url = PreferenceForm.API_MAIN_URL() + "notecalendar/create_holiday_note"; string json_string = "{\"date\":\"" + note.date + "\","; json_string += "\"type\":" + note.type.ToString() + ","; json_string += "\"description\":\"" + note.description + "\","; json_string += "\"group_maid\":\"" + note.group_maid + "\","; json_string += "\"group_weekend\":\"" + note.group_weekend + "\","; json_string += "\"max_leave\":" + note.max_leave.ToString() + ","; json_string += "\"rec_by\":\"" + note.rec_by + "\"}"; CRUDResult get = ApiActions.POST(url, json_string); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { return(true); } else if (sr.result == ServerResult.SERVER_CREATE_RESULT_FAILED_EXIST) { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); return(false); } else { if (MessageAlert.Show(sr.message, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry) { return(CreateHolidayNote(note)); } return(false); } }
private void submitChangeMacAddress() { string json_data = "{\"id\": " + this.editing_mac_id.ToString() + ","; json_data += "\"mac_address\":\"" + this.txtMacAddress.Text.cleanString() + "\","; json_data += "\"create_by\":\"" + this.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "macallowed/update", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (post.result) { switch (sr.result) { case ServerResult.SERVER_RESULT_SUCCESS: this.DialogResult = DialogResult.OK; this.Close(); break; default: MessageBox.Show(sr.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } else { MessageBox.Show(sr.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void showEditForm(int mac_id) { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "macallowed/get_at&mac_id=" + mac_id.ToString()); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (get.result) { MacAddressEditForm editForm = new MacAddressEditForm(); editForm.G = this.G; int id = sr.macallowed.First <MacAllowed>().id; string mac_address = sr.macallowed.First <MacAllowed>().mac_address; editForm.editing_mac_id = id; editForm.txtMacAddress.Text = mac_address; if (editForm.ShowDialog() == DialogResult.OK) { this.loadMacAddressData(mac_id); } } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } }
private void workerSave_Dowork(object sender, DoWorkEventArgs e) { string is_greendisc = this.chkGreendisc.CheckState.ToYesOrNoString(); string is_pinkdisc = this.chkPinkdisc.CheckState.ToYesOrNoString(); string json_data = "{\"id\":" + this.parent_form.serial.id.ToString() + ","; json_data += "\"verext\":\"" + this.verext + "\","; json_data += "\"is_greendisc\":\"" + is_greendisc + "\","; json_data += "\"is_pinkdisc\":\"" + is_pinkdisc + "\","; json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/up_new_rwt_line", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { this.parent_form.serial = sr.serial[0]; this.parent_form.problem = sr.problem; this.parent_form.problem_im_only = (sr.problem.Count > 0 ? sr.problem.Where <Problem>(t => t.probcod == "IM").ToList <Problem>() : new List <Problem>()); this.parent_form.verext = sr.verext[0]; this.save_result = true; } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); this.save_result = false; } }
private void inquireAll() { if (this.serial_list.Count == 0) { string ids = string.Empty; for (int i = 0; i <= 100; i++) { if (i == 0) { ids += this.serial_id_list[i].id.ToString(); } else { ids += "," + this.serial_id_list[i].id.ToString(); } } CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "serial/get_inquiry&sort=" + this.sortMode + "&ids=" + ids); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { if (sr.serial_list.Count > 0) { this.serial_list = sr.serial_list; this.toolStripLoadedRec.Text = this.serial_list.Count.ToString(); this.toolStripTotalRec.Text = this.serial_id_list.Count.ToString(); } } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } } }
private void btnOK_Click(object sender, EventArgs e) { bool post_success = false; this.formSaving(); BackgroundWorker workerSave = new BackgroundWorker(); workerSave.DoWork += delegate { string json_data = "{\"sernum\":\"" + this.mskSernum.Text + "\","; json_data += "\"qty\":" + this.numQty.Value.ToString() + ","; json_data += "\"version\":\"" + this.txtVersion.Text + "\","; json_data += "\"dealer\":\"" + this.txtDealer.Text + "\","; json_data += "\"is_newrwt\":\"" + this.chkNewRwt.CheckState.ToYesOrNoString() + "\","; json_data += "\"is_newrwtjob\":\"" + this.chkNewRwtJob.CheckState.ToYesOrNoString() + "\","; json_data += "\"is_cdtraining\":\"" + this.chkCDTraining.CheckState.ToYesOrNoString() + "\","; json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/generate_sn", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; this.parent_window.serial = sr.serial[0]; this.parent_window.busityp = (sr.busityp.Count > 0 ? sr.busityp[0] : new Istab()); this.parent_window.area = (sr.area.Count > 0 ? sr.area[0] : new Istab()); this.parent_window.howknown = (sr.howknown.Count > 0 ? sr.howknown[0] : new Istab()); this.parent_window.verext = (sr.verext.Count > 0 ? sr.verext[0] : new Istab()); this.parent_window.dealer = (sr.dealer.Count > 0 ? sr.dealer[0] : new Dealer()); this.parent_window.problem = new List <Problem>(); this.parent_window.problem_im_only = new List <Problem>(); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); post_success = false; } }; workerSave.RunWorkerCompleted += delegate { if (post_success) { this.DialogResult = DialogResult.OK; this.Close(); } else { this.formEdit(); } }; workerSave.RunWorkerAsync(); }
private void toolStripDelete_Click(object sender, EventArgs e) { if (this.dgvIstab.CurrentCell == null) { return; } if (this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag is Istab) { this.dgvIstab.Tag = DGV_TAG.DELETE; if (MessageAlert.Show(StringResource.CONFIRM_DELETE, "", MessageAlertButtons.OK_CANCEL, MessageAlertIcons.QUESTION) == DialogResult.OK) { this.FormProcessing(); Istab delete_item = (Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag; bool delete_success = false; string err_msg = ""; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { CRUDResult delete = ApiActions.DELETE(PreferenceForm.API_MAIN_URL() + "istab/delete&id=" + ((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag).id.ToString()); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(delete.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { delete_success = true; } else { delete_success = false; err_msg = sr.message; } }; worker.RunWorkerCompleted += delegate { if (delete_success) { int delete_row_index = this.dgvIstab.Rows.Cast <DataGridViewRow>().Where(r => ((Istab)r.Tag).id == delete_item.id).First <DataGridViewRow>().Cells[1].RowIndex; this.GetIstabData(null, false, delete_row_index); } else { MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); this.dgvIstab.Tag = DGV_TAG.NORMAL; this.FormRead(); } }; worker.RunWorkerAsync(); } else { this.FillInDatagrid((Istab)this.dgvIstab.Rows[this.dgvIstab.CurrentCell.RowIndex].Tag); } } }
private void btnOK_Click(object sender, EventArgs e) { TimeSpan ts = TimeSpan.Parse(this.tmTo.Value.Hour.ToString() + ":" + this.tmTo.Value.Minute.ToString() + ":00") - TimeSpan.Parse(this.tmFrom.Value.Hour.ToString() + ":" + this.tmFrom.Value.Minute.ToString() + ":00"); if (this.support_note == null) // add mode { string json_data = "{\"date\":\"" + this.date.ToMysqlDate() + "\","; json_data += "\"sernum\":\"\","; json_data += "\"start_time\":\"" + this.tmFrom.Text + ":00\","; json_data += "\"end_time\":\"" + this.tmTo.Text + ":00\","; json_data += "\"duration\":\"" + ts.ToString().Substring(0, 8) + "\","; json_data += "\"reason\":\"" + SupportNote.BREAK_REASON.TRAINING_TRAINER.FormatBreakReson() + "\","; json_data += "\"remark\":\"\","; json_data += "\"users_name\":\"" + this.user.username + "\","; json_data += "\"is_break\":\"Y\","; json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/create_break", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } } else // update mode { string json_data = "{\"id\":" + this.support_note.id.ToString() + ","; json_data += "\"date\":\"" + this.date.ToMysqlDate() + "\","; json_data += "\"sernum\":\"\","; json_data += "\"start_time\":\"" + this.tmFrom.Text + ":00\","; json_data += "\"end_time\":\"" + this.tmTo.Text + ":00\","; json_data += "\"duration\":\"" + ts.ToString().Substring(0, 8) + "\","; json_data += "\"reason\":\"" + SupportNote.BREAK_REASON.TRAINING_TRAINER.FormatBreakReson() + "\","; json_data += "\"remark\":\"\","; json_data += "\"users_name\":\"" + this.user.username + "\","; json_data += "\"is_break\":\"Y\","; json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}"; CRUDResult post = 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) { this.DialogResult = DialogResult.OK; this.Close(); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } } }
private void GetServerData(string route_path) { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + route_path); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); this.macloud_list = sr.macloud_list; this.macloud_list_filtered = this.macloud_list.FindAll(m => m.SERIAL_ID > -1); this.bs.DataSource = this.macloud_list_filtered; this.bs.ResetBindings(true); }
private void LoadDependenciesData() { CRUDResult get_users = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_all"); ServerResult sr_users = JsonConvert.DeserializeObject <ServerResult>(get_users.data); if (sr_users.result == ServerResult.SERVER_RESULT_SUCCESS) { this.list_users = sr_users.users; } }
private void SaveCloudSrv() { bool post_success = false; string err_msg = ""; this.cloudDateFrom.Read_Only = true; this.cloudDateTo.Read_Only = true; this.cloudEmail.Read_Only = true; string json_data = "{\"sernum\":\"" + this.parent_window.serial.sernum.cleanString() + "\","; json_data += "\"start_date\":\"" + this.date_from.ToMysqlDate() + "\","; json_data += "\"end_date\":\"" + this.date_to.ToMysqlDate() + "\","; json_data += "\"email\":\"" + this.email.cleanString() + "\","; json_data += "\"rec_by\":\"" + this.parent_window.main_form.G.loged_in_user_name + "\"}"; Console.WriteLine(" ... > " + json_data); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "cloudsrv/create_or_update", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; } else { post_success = false; err_msg = sr.message; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.DialogResult = DialogResult.OK; this.Close(); } else { if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry) { this.SaveCloudSrv(); } this.cloudDateFrom.Read_Only = false; this.cloudDateTo.Read_Only = false; this.cloudEmail.Read_Only = false; } }; worker.RunWorkerAsync(); }
private void btnSubmit_Click(object sender, EventArgs e) { if (this.txtTypcod.Text.Length > 0) { CRUDResult post; if (this.mode == FORM_MODE.ADD) // Add { Console.WriteLine("current tabtyp = " + Istab.getTabtypString(this.tabtyp)); string json_data = "{\"tabtyp\":\"" + Istab.getTabtypString(this.tabtyp) + "\","; json_data += "\"typcod\":\"" + this.txtTypcod.Text.cleanString() + "\","; json_data += "\"abbreviate_en\":\"" + this.txtAbbreviate_en.Text.cleanString() + "\","; json_data += "\"abbreviate_th\":\"" + this.txtAbbreviate_th.Text.cleanString() + "\","; json_data += "\"typdes_en\":\"" + this.txtTypdes_en.Text.cleanString() + "\","; json_data += "\"typdes_th\":\"" + this.txtTypdes_th.Text.cleanString() + "\"}"; Console.WriteLine(json_data); post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/create", json_data); } else // Edit { string json_data = "{\"id\":" + this.istab.id.ToString() + ","; json_data += "\"tabtyp\":\"" + this.istab.tabtyp + "\","; json_data += "\"typcod\":\"" + this.istab.typcod + "\","; json_data += "\"abbreviate_en\":\"" + this.txtAbbreviate_en.Text.cleanString() + "\","; json_data += "\"abbreviate_th\":\"" + this.txtAbbreviate_th.Text.cleanString() + "\","; json_data += "\"typdes_en\":\"" + this.txtTypdes_en.Text.cleanString() + "\","; json_data += "\"typdes_th\":\"" + this.txtTypdes_th.Text.cleanString() + "\"}"; Console.WriteLine(json_data); post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/submit_change", json_data); } ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); Console.WriteLine(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { if (sr.istab != null) { this.istab = sr.istab[0]; } this.DialogResult = DialogResult.OK; this.Close(); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } } else { MessageAlert.Show(StringResource.PLEASE_FILL_CODE, "Warning", MessageAlertButtons.OK, MessageAlertIcons.WARNING); this.txtTypcod.Focus(); } }
private void btnOK_Click(object sender, EventArgs e) { this.formSaving(); bool post_success = false; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { string json_data = "{\"id\":" + this.parent_window.serial.id.ToString() + ","; json_data += "\"sernum_old\":\"" + this.mskOldSernum.Text + "\","; json_data += "\"sernum_2\":\"" + this.msk2Sernum.Text + "\","; json_data += "\"version\":\"" + this.txtVersion.Text + "\","; json_data += "\"dealer_dealer\":\"" + this.txtDealer.Text + "\","; json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/sell_program_2nd", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; this.parent_window.serial = sr.serial[0]; this.parent_window.busityp = (sr.busityp.Count > 0 ? sr.busityp[0] : new Istab()); this.parent_window.area = (sr.area.Count > 0 ? sr.area[0] : new Istab()); this.parent_window.howknown = (sr.howknown.Count > 0 ? sr.howknown[0] : new Istab()); this.parent_window.verext = (sr.verext.Count > 0 ? sr.verext[0] : new Istab()); this.parent_window.dealer = (sr.dealer.Count > 0 ? sr.dealer[0] : new Dealer()); this.parent_window.problem = (sr.problem.Count > 0 ? sr.problem : new List <Problem>()); this.parent_window.problem_im_only = (sr.problem.Count > 0 ? this.parent_window.problem.Where <Problem>(t => t.probcod == "IM").ToList <Problem>() : new List <Problem>()); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); post_success = false; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.DialogResult = DialogResult.OK; this.Close(); } else { this.formEdit(); } }; worker.RunWorkerAsync(); }
private void getDealer() { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "dealer/get_list"); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { if (sr.dealer != null) { this.dealers = sr.dealer; } } }
private void UpdateData() { this.FormProcessing(); Istab data = this.GetDataInForm(); bool post_success = false; string err_msg = ""; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { string json_data = "{\"id\":" + data.id.ToString() + ","; json_data += "\"tabtyp\":\"" + Istab.getTabtypString(this.tabtyp) + "\","; json_data += "\"typcod\":\"" + data.typcod.cleanString() + "\","; json_data += "\"abbreviate_th\":\"" + data.abbreviate_th.cleanString() + "\","; json_data += "\"abbreviate_en\":\"" + data.abbreviate_en.cleanString() + "\","; json_data += "\"typdes_th\":\"" + data.typdes_th.cleanString() + "\","; json_data += "\"typdes_en\":\"" + data.typdes_en.cleanString() + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "istab/submit_change", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; } else { post_success = false; err_msg = sr.message; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.GetIstabData(data); } else { MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); this.FormEdit(); if (this.dgvIstab.Parent.Controls.Find("inline_typdes_en", true).Length > 0) { ((CustomTextBox)this.dgvIstab.Parent.Controls.Find("inline_typdes_en", true)[0]).textBox1.Focus(); } } }; worker.RunWorkerAsync(); }
private void btnOK_Click(object sender, EventArgs e) { bool post_success = false; this.formSaving(); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { string json_data = "{\"id\":" + this.parent_window.serial.id.ToString() + ","; json_data += "\"sernum_from\":\"" + this.mskSernumFrom.Text + "\","; json_data += "\"sernum_to\":\"" + this.mskSernumTo.Text + "\","; json_data += "\"version\":\"" + this.txtVersion.Text + "\","; json_data += "\"is_cdtraining\":\"" + this.chkCDTraining.CheckState.ToYesOrNoString() + "\","; json_data += "\"is_newrwt\":\"" + this.chkNewRwt.CheckState.ToYesOrNoString() + "\","; json_data += "\"is_newrwt_job\":\"" + this.chkNewRwtJob.CheckState.ToYesOrNoString() + "\","; json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serial/upgrade_program", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; this.parent_window.serial = sr.serial[0]; this.parent_window.problem = sr.problem; this.parent_window.problem_im_only = (sr.problem.Count > 0 ? sr.problem.Where <Problem>(t => t.probcod == "IM").ToList <Problem>() : new List <Problem>()); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); post_success = false; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.DialogResult = DialogResult.OK; this.Close(); } else { this.formEdit(); } }; worker.RunWorkerAsync(); }
private void LoadDependenciesData() { #region Load users_list from server CRUDResult get_user = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_all"); ServerResult sr_user = JsonConvert.DeserializeObject <ServerResult>(get_user.data); if (sr_user.result == ServerResult.SERVER_RESULT_SUCCESS) { this.list_users = sr_user.users; } #endregion Load users_list from server this.BindingControlEventHandler(); }
public static List <Istab> GetIstab(string tabtyp) { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "istab/get_all&tabtyp=" + tabtyp + "&sort=typcod"); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { return(sr.istab); } else { return(new List <Istab>()); } }
private void LoadDealerListData(int start_list_id, int stop_list_id) { this.FormProcessing(); bool post_success = false; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { string ids = string.Empty; for (int i = start_list_id; i <= stop_list_id; i++) { if (i == 0) { ids += this.dealer_id_list[i].id.ToString(); } else { ids += "," + this.dealer_id_list[i].id.ToString(); } } string json_data = "{\"ids\":\"" + ids + "\","; json_data += "\"sort_field\":\"" + this.sort_field + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "dealer/get_inquiry", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { this.dealer_list = sr.dealer_list; post_success = true; } else { post_success = false; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.toolStripLoadedRec.Text = this.dealer_list.Count.ToString(); this.toolStripTotalRec.Text = this.dealer_list.Count.ToString(); this.FillDataGrid(); this.FormRead(); } }; worker.RunWorkerAsync(); }
private void SubmitPassword() { bool post_success = false; string err_msg = ""; string json_data = "{\"sernum\":\"" + this.sn_wind.serial.sernum + "\","; json_data += "\"pass_word\":\"" + this.txtPassword.Texts.cleanString() + "\","; json_data += "\"rec_by\":\"" + this.main_form.G.loged_in_user_name + "\"}"; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "serialpassword/create", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { post_success = true; this.inserted_id = (sr.serial_password.Count > 0 ? sr.serial_password[0].id : -1); } else { post_success = false; err_msg = sr.message; } }; worker.RunWorkerCompleted += delegate { if (post_success) { this.DialogResult = DialogResult.OK; this.Close(); } else { if (MessageAlert.Show(err_msg, "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry) { this.SubmitPassword(); // if error occured and retry again return; } this.btnCancel.PerformClick(); // if error occured and do not retry } }; worker.RunWorkerAsync(); }
public static List <NoteCalendar> GetNoteCalendarList(int year) { string url = PreferenceForm.API_MAIN_URL() + "notecalendar/get_holiday_note&year=" + year.ToString(); CRUDResult get = ApiActions.GET(url); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { return(sr.note_calendar); } else { return(null); } }
public static List <Users> GetUsers() { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_all"); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); return(sr.users); //if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) //{ // return sr.users; //} //else //{ // return new List<Users>(); //} }
public static NoteCalendar GetSingleNoteCalendar(DateTime date) { string url = PreferenceForm.API_MAIN_URL() + "notecalendar/get_single_note&date=" + date.ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US")); CRUDResult get = ApiActions.GET(url); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { return(sr.note_calendar.FirstOrDefault()); } else { return(null); } }
private List <Users> GetTrainerAll() { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "users/get_trainer"); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { return(sr.users); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); return(null); } }
private List <Users> GetTrainerSelected() { CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "trainingcalendar/get_trainer&date_from=" + this.date_event.Date.ToMysqlDate() + "&date_to=" + this.date_event.Date.ToMysqlDate()); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(get.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { return(sr.users); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); return(null); } }
private void btnBrowse_Click(object sender, EventArgs e) { string app_dir = AppDomain.CurrentDomain.BaseDirectory; if (this.txtFilePath.Text.Trim().Length > 0) { try { if (Directory.Exists(Path.GetDirectoryName(this.txtFilePath.Text))) { this.openFileDialog1.InitialDirectory = Path.GetDirectoryName(this.txtFilePath.Text); this.openFileDialog1.FileName = this.txtFilePath.Text; } else { this.openFileDialog1.InitialDirectory = app_dir; } } catch (DirectoryNotFoundException ex) { this.openFileDialog1.InitialDirectory = app_dir; throw; } } else { this.openFileDialog1.InitialDirectory = app_dir; } if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string json_data = "{\"id\":" + this.note_id.ToString() + ","; json_data += "\"file_path\":\"" + this.openFileDialog1.FileName.cleanString() + "\"}"; CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "supportnote/save_file_path", json_data); ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(post.data); if (sr.result == ServerResult.SERVER_RESULT_SUCCESS) { this.parent_wind.GetSingleNote(this.note_id); this.txtFilePath.Text = (this.parent_wind.supportnote_list.Find(t => t.id == this.note_id) != null ? (this.parent_wind.supportnote_list.Find(t => t.id == this.note_id).file_path != null ? this.parent_wind.supportnote_list.Find(t => t.id == this.note_id).file_path : "") : ""); } else { MessageAlert.Show(sr.message, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR); } } }
private void preferenceToolStripMenuItem_Click(object sender, EventArgs e) { PreferenceForm wind = new PreferenceForm(); wind.ShowDialog(); }
public static string API_MAIN_URL() { PreferenceForm pref = new PreferenceForm(); return pref.readPreferenceLine(MAIN_URL); }
public static int BREAK_TIME_METHOD_CONFIGURATION() { PreferenceForm pref = new PreferenceForm(); return (pref.readPreferenceLine(BREAK_TIME_METHOD).Length == 0 ? (int)BREAK_TIME.AUTO : Convert.ToInt32(pref.readPreferenceLine(BREAK_TIME_METHOD))); }
private void btnPreference_Click(object sender, EventArgs e) { PreferenceForm wind = new PreferenceForm(); wind.ShowDialog(); }
public static int SEARCH_NOTE_DATE_CONFIGURATION() { PreferenceForm pref = new PreferenceForm(); return (pref.readPreferenceLine(SEARCH_NOTE_DATE).Length == 0 ? (int)SEARCH_DATE.CURRENT_DATE : Convert.ToInt32(pref.readPreferenceLine(SEARCH_NOTE_DATE))); }
public static int SEARCH_NOTE_METHOD_CONFIGURATION() { PreferenceForm pref = new PreferenceForm(); return (pref.readPreferenceLine(SEARCH_NOTE_METHOD).Length == 0 ? (int)SEARCH_NOTE.PRIVATE : Convert.ToInt32(pref.readPreferenceLine(SEARCH_NOTE_METHOD))); }