private void btnSave_Click(object sender, EventArgs e) { if (GlobalMessageBox.ShowQuestion("คุณต้องการบันทึกข้อมูล ใช่หรือไม่") == DialogResult.Yes) { try { Cursor.Current = Cursors.WaitCursor; var productLocations = (List <ProductLocation>)bsLocation.DataSource; foreach (var item in productLocations) { item.ProductCode = txtProductCode.Text; item.ProductUnitCode = txtUnitCode.Text; item.ProductName = txtProductName.Text; item.BalanceQuantitySpecified = true; } ServiceHelper.MobileServices.ProductLocationBlankAdd(GlobalContext.BranchCode, productLocations.ToArray()); GlobalMessageBox.ShowInfomation("บันทึกข้อมูลเรียบร้อยแล้ว"); ClearGrid(); } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsValidateForm) { if (GlobalMessageBox.ShowQuestion("คุณต้องการบันทึกเอกสารนี้ ใช่หรือไม่") == DialogResult.Yes) { try { Cursor.Current = Cursors.WaitCursor; grdProduct.EndEdit(); List <HandHeldCounterHold> products = (List <HandHeldCounterHold>)bindingSource.DataSource; foreach (var item in products) { item.Warehouse = GlobalContext.WarehouseCode; item.Branchcode = GlobalContext.BranchCode; item.QuantitySpecified = true; item.Officerid = GlobalContext.UserCode;//ddlEmployee.SelectedValue as string; item.Createuser = GlobalContext.UserCode; } string messageStatus = string.Empty; // save data to server. var documentNo = ServiceHelper.MobileServices.AddHandHeldCounterHold(GlobalContext.BranchCode, products.ToArray()); var message = ServiceHelper.MobileServices.AddHandHeldCounter(GlobalContext.BranchCode, documentNo, false, out messageStatus); //lblMessage.Text = messageStatus; //lblMessage.Visible = true; if (message.IndexOf("true") > -1) { GlobalMessageBox.ShowInfomation(message); } else if (message.IndexOf("false") > -1) { if (GlobalMessageBox.ShowQuestion(message) == DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; message = ServiceHelper.MobileServices.AddHandHeldCounter(GlobalContext.BranchCode, documentNo, true, out messageStatus); GlobalMessageBox.ShowInfomation(message); } else { this.ClearControlBinding(); } } } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } finally { Cursor.Current = Cursors.Default; } } } }
private void btnLevelAdd_Click(object sender, EventArgs e) { var oForm = new LocationProductForm(this.OfflineMode); if (oForm.ShowDialog() == DialogResult.OK) { if (oForm.ProductLocation == null) { return; } if (bsLocation.DataSource == null) { bsLocation.DataSource = new List <ProductLocation>(); } var location = oForm.ProductLocation; var locations = (List <ProductLocation>)bsLocation.DataSource; var productLocation = locations.Find(p => p.ProductCode == location.ProductCode); if (productLocation != null)// update { if (GlobalMessageBox.ShowQuestion("มีสินค้านี้อยู่ในตำแหน่งแล้ว\nคุณต้องการแก้ไขสินค้านี้ ใช่หรือไม่ ?") == DialogResult.Yes) { productLocation.ProductBarcode = oForm.ProductLocation.ProductBarcode; productLocation.ProductCode = oForm.ProductLocation.ProductCode; productLocation.PutLevel = oForm.ProductLocation.PutLevel; productLocation.ProductName = oForm.ProductLocation.ProductName; productLocation.PutQuantity = oForm.ProductLocation.PutQuantity; productLocation.ProductUnitCode = oForm.ProductLocation.ProductUnitCode; productLocation.ProductUnitName = oForm.ProductLocation.ProductUnitName; productLocation.RequestPrintLabel = oForm.ProductLocation.RequestPrintLabel; productLocation.RequestPrintLabelSpecified = true; productLocation.MaxStock = oForm.ProductLocation.MaxStock; productLocation.MaxStockSpecified = true; bsLocation.ResetBindings(false); btnAdd.Focus(); return; } else { return; } } else // add { locations.Add(location); bsLocation.ResetBindings(false); this.Reindex(); btnLevelAdd_Click(sender, e); } } _currentRowIndex = dgLocation.VisibleRowCount - 1; GridSelected(); }
private void LocationForm_Closing(object sender, CancelEventArgs e) { if (btnSave.Enabled) { if (GlobalMessageBox.ShowQuestion("คุณยังไม่ทำการบันทึกข้อมูล\nคุณต้องการบันทึกข้อมูล ใช่หรือไม่") == DialogResult.Yes) { e.Cancel = true; } } }
private void MainForm_Closing(object sender, CancelEventArgs e) { if (GlobalMessageBox.ShowQuestion("คุณต้องการออกจากโปรแกรม ใช่หรือไม่ ?") == DialogResult.Yes) { e.Cancel = false; } else { e.Cancel = true; } }
private void AddOnLineMode() { var productLocations = (List <ProductLocation>)bsLocation.DataSource; if (productLocations.Exists(p => p.RequestPrintLabel) && cmbLabelType.SelectedIndex == 0) { GlobalMessageBox.ShowInfomation("กรุณาเลือกประเภทป้าย\nก่อนบันทึกข้อมูล"); return; } if (GlobalMessageBox.ShowQuestion("คุณต้องการบันทึกข้อมูล ใช่หรือไม่") == DialogResult.Yes) { try { Cursor.Current = Cursors.WaitCursor; this.PrepareSave(); string result = string.Empty; productLocations = (List <ProductLocation>)bsLocation.DataSource; result = ServiceHelper.MobileServices.ProductLocationAdd(GlobalContext.BranchCode, txtLocationCodeScan.Text.Trim() , GlobalContext.WarehouseCode , productLocations.ToArray()); if (!"ERROR".Equals(result)) { string message = string.Empty; if (result.Contains("PL")) { message = "บันทึกข้อมูลเรียบร้อย\nเลขที่เอกสารพิมพ์ป้ายที่ได้\n" + result; } else { message = "บันทึกข้อมูลเรียบร้อย"; } GlobalMessageBox.ShowInfomation(message); // call btnClear button btnClear_Click(null, null); } else { GlobalMessageBox.ShowError("บันทึกข้อมูลไม่สำเร็จ กรุณาติดต่อผู้ดูแล"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "พบข้อผิดพลาด"); } finally { Cursor.Current = Cursors.Default; } } }
private void gvLocationProduct_CellClick(object sender, Resco.Controls.SmartGrid.CellEventArgs e) { //click on delete column if (e.Cell.ColumnIndex == 2) { if (GlobalMessageBox.ShowQuestion("คุณต้องลบรายการ ใช่หรือไม่") == DialogResult.Yes) { var locationCode = gvLocationProduct.Cells[e.Cell.RowIndex, 0].Text; LocationCheckProductManager.Delete(locationCode); this.BindGrid(); } } }
private void gvLocationProduct_CellClick(object sender, Resco.Controls.SmartGrid.CellEventArgs e) { //click on delete column if (e.Cell.ColumnIndex == 2) { if (GlobalMessageBox.ShowQuestion("คุณต้องลบรายการ ใช่หรือไม่") == DialogResult.Yes) { var id = Convert.ToInt32(gvLocationProduct.Cells[e.Cell.RowIndex, 3].Text); Delete(id); this.BindGrid(); } } }
private void grdLocations_CellClick(object sender, Resco.Controls.SmartGrid.CellEventArgs e) { //click on delete column if (e.Cell.ColumnIndex == 2) { if (GlobalMessageBox.ShowQuestion("คุณต้องลบรายการ ใช่หรือไม่") == DialogResult.Yes) { var id = Convert.ToInt32(grdLocations.Cells[e.Cell.RowIndex, 0].Text); _labelLocation.RemoveAll(p => p.Id == id); this.BindGridview(); } } }
private void btnHoldBill_Click(object sender, EventArgs e) { if (IsValidateForm) { //string ShopRemark = oForm.Remark; var oForm = new EnterRemark(); if (oForm.ShowDialog() == DialogResult.OK) { // ShopRemark = oForm.Remark; } if (GlobalMessageBox.ShowQuestion("คุณต้องการพักบิลเอกสารนี้ ใช่หรือไม่") == DialogResult.Yes) { try { Cursor.Current = Cursors.WaitCursor; grdProduct.EndEdit(); List <HandHeldCounterHold> products = (List <HandHeldCounterHold>)bindingSource.DataSource; foreach (var item in products) { item.Warehouse = GlobalContext.WarehouseCode; item.Branchcode = GlobalContext.BranchCode; item.QuantitySpecified = true; item.Officerid = GlobalContext.UserCode;//ddlEmployee.SelectedValue as string; item.Createuser = GlobalContext.UserCode; } // save data to server. ServiceHelper.MobileServices.AddHandHeldCounterHold(GlobalContext.BranchCode, products.ToArray()); GlobalMessageBox.ShowInfomation("พักบิลเรียบร้อยแล้ว"); this.ClearControlBinding(); } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } finally { Cursor.Current = Cursors.Default; } } } }
private bool CheckIsCreateLocationToday() { var locationCode = txtLocationCode.Text.Trim(); bool checkIsCreateLocationToday = false; checkIsCreateLocationToday = ServiceHelper.MobileServices.CheckIsCreateLocationToday(GlobalContext.BranchCode, locationCode , GlobalContext.WarehouseCode); if (checkIsCreateLocationToday) { if (GlobalMessageBox.ShowQuestion("ตำแหน่ง " + locationCode + " เคยทำแล้วในวันนี้ ต้องการทำซ้ำอีกครั้งหรือไม่?") == DialogResult.Yes) { return(true); } else { return(false); } } return(true); }
private void gvLocationProduct_CellClick(object sender, Resco.Controls.SmartGrid.CellEventArgs e) { //click on delete column if (e.Cell.ColumnIndex == 2) { if (GlobalMessageBox.ShowQuestion("คุณต้องลบรายการ ใช่หรือไม่") == DialogResult.Yes) { var locationCode = gvLocationProduct.Cells[e.Cell.RowIndex, 0].Text; using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString)) { con.Open(); using (SqlCeCommand com = new SqlCeCommand(SqlHelper.GetSql(30), con)) { com.Parameters.AddWithValue("@LocationCode", locationCode); com.Parameters.AddWithValue("@CreatedBy", GlobalContext.UserCode); com.ExecuteNonQuery(); } } this.BindGrid(); } } }
private void HoldBill() { if (IsValidateForm) { if (GlobalMessageBox.ShowQuestion("คุณต้องการพักบิลเอกสารนี้ ใช่หรือไม่") == DialogResult.Yes) { try { Cursor.Current = Cursors.WaitCursor; var counterHolds = (HandHeldCounterMainHold[])bindingSource.DataSource; foreach (var item in counterHolds) { item.Createuser = GlobalContext.UserCode; item.ErfmgSalesSpecified = true; item.ErfmgSkuSpecified = true; } // save data to server. ServiceHelper.MobileServices.AddHandHeldCounterMainHold(GlobalContext.BranchCode, counterHolds); GlobalMessageBox.ShowInfomation("พักบิลเรียบร้อยแล้ว"); this.ClearControlBinding(); } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } finally { Cursor.Current = Cursors.Default; } } } }
private void btnInsert_Click(object sender, EventArgs e) { //var rowIndex = dgLocation.CurrentCell.RowNumber; var locations = (List <ProductLocation>)bsLocation.DataSource; //var displayOrder = locations.Find(p => p.ProductCode == this.GetCurrentProductCode()).DisplayOrder; var displayOrder = _currentRowIndex; var oForm = new LocationProductForm(this.OfflineMode); if (oForm.ShowDialog() == DialogResult.OK) { if (bsLocation.DataSource == null) { bsLocation.DataSource = new List <ProductLocation>(); } var location = oForm.ProductLocation; if (location == null) { return; } var productLocation = locations.Find(p => p.ProductBarcode == location.ProductBarcode); if (productLocation != null) { if (GlobalMessageBox.ShowQuestion("มีสินค้านี้อยู่ในตำแหน่งแล้ว\nคุณต้องการแก้ไขสินค้านี้ ใช่หรือไม่ ?") == DialogResult.Yes) { productLocation.ProductBarcode = oForm.ProductLocation.ProductBarcode; productLocation.ProductCode = oForm.ProductLocation.ProductCode; productLocation.PutLevel = oForm.ProductLocation.PutLevel; productLocation.ProductName = oForm.ProductLocation.ProductName; productLocation.PutQuantity = oForm.ProductLocation.PutQuantity; productLocation.ProductUnitCode = oForm.ProductLocation.ProductUnitCode; productLocation.ProductUnitName = oForm.ProductLocation.ProductUnitName; productLocation.RequestPrintLabel = oForm.ProductLocation.RequestPrintLabel; productLocation.RequestPrintLabelSpecified = true; productLocation.MaxStock = oForm.ProductLocation.MaxStock; productLocation.MaxStockSpecified = true; bsLocation.ResetBindings(false); return; } else { return; } } if (displayOrder == 0) { locations.Insert(0, location); } else { locations.Insert(displayOrder, location); } //locations.Insert(displayOrder - 1, location); bsLocation.ResetBindings(false); this.Reindex(); _currentRowIndex = displayOrder; GridSelected(); } }