public IstabAddEditDialog(IstabDialog istab_dialog, ISTAB_TABTYP tabtyp, IstabVM istab = null) { InitializeComponent(); this.main_form = istab_dialog.main_form; this.istab_dialog = istab_dialog; this.form_mode = istab != null ? FORM_MODE.EDIT : FORM_MODE.ADD; this.istab = istab; this.tabtyp = tabtyp; }
private void btnDelete_Click(object sender, EventArgs e) { if (this.gridViewIstab.GetRow(this.gridViewIstab.FocusedRowHandle) == null) { return; } IstabVM istab = this.istab.Where(i => i.Id == (int)this.gridViewIstab.GetRowCellValue(this.gridViewIstab.FocusedRowHandle, this.colId)).FirstOrDefault(); if (istab == null) { return; } if (MessageBox.Show("ลบรหัส \"" + istab.TypCod + "\" ทำต่อหรือไม่?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { this.splashScreenManager1.ShowWaitForm(); ApiAccessibilities acc = new ApiAccessibilities { API_KEY = this.main_form.config.ApiKey, istab = istab }; APIResult delete = APIClient.DELETE(this.main_form.config.ApiUrl + "Istab/DeleteIstab", acc); if (delete.Success) { this.istab = this.LoadIstabFromServer(); this.bs.ResetBindings(true); this.bs.DataSource = this.istab; this.splashScreenManager1.CloseWaitForm(); } else { this.splashScreenManager1.CloseWaitForm(); if (MessageBox.Show(delete.ErrorMessage.RemoveBeginAndEndQuote(), "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { this.btnDelete.PerformClick(); } } } }
public IstabVM LoadSingleIstabFromServer(int id) { APIResult get = APIClient.GET(this.main_form.config.ApiUrl + "Istab/GetIstabAt", this.main_form.config.ApiKey, "&id=" + id); if (get.Success) { IstabVM istab = JsonConvert.DeserializeObject <IstabVM>(get.ReturnValue); return(istab); } else { if (MessageBox.Show("", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) { return(this.LoadSingleIstabFromServer(id)); } else { return(null); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (this.gridViewIstab.GetRow(this.gridViewIstab.FocusedRowHandle) == null) { return; } IstabVM istab = this.istab.Where(i => i.Id == (int)this.gridViewIstab.GetRowCellValue(this.gridViewIstab.FocusedRowHandle, this.colId)).FirstOrDefault(); if (istab == null) { return; } IstabAddEditDialog edit = new IstabAddEditDialog(this, this.tabtyp, istab); if (edit.ShowDialog() == DialogResult.OK) { this.istab = this.LoadIstabFromServer(); this.bs.ResetBindings(true); this.bs.DataSource = this.istab; } }
public static StmasImportVM ToViewModel(this Stmas stmas, List <Istab> stkgrp_list, List <Istab> qucod_list) { if (stmas == null) { return(null); } var grp = stkgrp_list.Where(i => i.typcod.Trim() == stmas.stkgrp.Trim()).FirstOrDefault(); var stkgrp = new IstabVM { TabTyp = ((int)ISTAB_TABTYP.STKGRP).ToString(), TypCod = stmas.stkgrp.Trim() }; if (grp != null) { stkgrp.AbbreviateTh = grp.shortnam.Trim(); stkgrp.AbbreviateEn = grp.shortnam2.Trim(); stkgrp.TypDesTh = grp.typdes.Trim(); stkgrp.TypDesEn = grp.typdes2.Trim(); } else { stkgrp.AbbreviateTh = ""; stkgrp.AbbreviateEn = ""; stkgrp.TypDesTh = ""; stkgrp.TypDesEn = ""; } var qu = qucod_list.Where(i => i.typcod.Trim() == stmas.qucod.Trim()).FirstOrDefault(); var qucod = new IstabVM { TabTyp = ((int)ISTAB_TABTYP.QUCOD).ToString(), TypCod = stmas.qucod.Trim() }; if (qu != null) { qucod.AbbreviateTh = qu.shortnam.Trim(); qucod.AbbreviateEn = qu.shortnam2.Trim(); qucod.TypDesTh = qu.typdes.Trim(); qucod.TypDesEn = qu.typdes2.Trim(); } else { qucod.AbbreviateTh = ""; qucod.AbbreviateEn = ""; qucod.TypDesTh = ""; qucod.TypDesEn = ""; } StmasImportVM st = new StmasImportVM { Stkcod = stmas.stkcod, StkDesTh = stmas.stkdes, StkDesEn = stmas.stkdes2, Barcod = stmas.barcod, StkTyp = stmas.stktyp, //StkGrp = stmas.StkGrp, //Qucod = stmas.Qucod, Sellpr1 = (decimal)stmas.sellpr1, Sellpr2 = (decimal)stmas.sellpr2, Sellpr3 = (decimal)stmas.sellpr3, Sellpr4 = (decimal)stmas.sellpr4, Sellpr5 = (decimal)stmas.sellpr5, //ProductImg = stmas.ProductImg, _StkGrp = stkgrp, _QuCod = qucod }; return(st); }
public static IstabVM IstabVM2IstabVM(IstabVM istab) { return(istab); }
private void IstabAddEditDialog_Load(object sender, EventArgs e) { switch (this.tabtyp) { case ISTAB_TABTYP.QUCOD: this.txtTypCod.Properties.MaxLength = 2; break; case ISTAB_TABTYP.LOCCOD: this.txtTypCod.Properties.MaxLength = 4; break; case ISTAB_TABTYP.STKGRP: this.txtTypCod.Properties.MaxLength = 4; break; case ISTAB_TABTYP.DLVBY: this.txtTypCod.Properties.MaxLength = 2; break; case ISTAB_TABTYP.DEPCOD: this.txtTypCod.Properties.MaxLength = 4; break; case ISTAB_TABTYP.YOUREF_AR: this.txtTypCod.Properties.MaxLength = 8; break; default: this.txtTypCod.Properties.MaxLength = 2; break; } if (this.form_mode == FORM_MODE.ADD) { this.Text = "เพิ่ม" + this.tabtyp.GetDescription(); this.istab = new IstabVM { TabTyp = ((int)this.tabtyp).ToString(), TypCod = string.Empty, AbbreviateEn = string.Empty, AbbreviateTh = string.Empty, TypDesEn = string.Empty, TypDesTh = string.Empty, Rate = 0, CreBy = this.main_form.logedin_user.Id }; } if (this.form_mode == FORM_MODE.EDIT) { this.Text = "แก้ไข" + this.tabtyp.GetDescription(); this.istab = this.istab_dialog.LoadSingleIstabFromServer(this.istab.Id); this.istab.ChgBy = this.main_form.logedin_user.Id; this.txtTypCod.Enabled = false; } this.txtTypCod.Text = this.istab.TypCod; this.txtAbbrTh.Text = this.istab.AbbreviateTh; this.txtAbbrEn.Text = this.istab.AbbreviateEn; this.txtTypDesTh.Text = this.istab.TypDesTh; this.txtTypDesEn.Text = this.istab.TypDesEn; }