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 bool ValidateForm() { if (string.IsNullOrEmpty(txtEmployeeCode.Text)) { GlobalMessageBox.ShowInfomation("กรุณาเลือกพนักงานประจำล็อก ก่อนทำการบันทึก"); txtEmployeeCode.Focus(); return(false); } return(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 btnPurchaseInfo_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtProductCode.Text)) { GlobalMessageBox.ShowInfomation("กรุณาระบุสินค้าก่อนดูข้อมูล"); return; } var oForm = new PurchaseInfoForm(txtProductCode.Text, txtProductName.Text, txtGroupingofmaterials.Text); oForm.ShowDialog(); }
private void btnScanerFix_Click(object sender, EventArgs e) { try { CeReader.Barcode.FreeModule(); CeReader.Barcode.InitModule(); GlobalMessageBox.ShowInfomation("แก้ไขระบบสแกนเรียบร้อยแล้ว กรุณาทดสอบการสแกนบาร์โค้ดอีกครั้ง"); } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } }
private void BindLocationData() { var locationCode = txtLocationCode.Text.ToUpper(); if (locationCode.IndexOf(Convert.ToChar(".")) > -1) { txtLocationCode.Text = null; txtLocationCode.Focus(); return; } else if (Utils.CheckIsDigitOnly(locationCode)) { txtLocationCode.Text = null; txtLocationCode.Focus(); return; } try { Cursor.Current = Cursors.WaitCursor; if (!OfflineMode) { var EndPoint = GlobalContext.ServerEndpointAddress; var ServiceUrl = GlobalContext.remoteAddress; var cnn = new DoHome.HandHeld.Client.SAPCnn.MobileService(); cnn.Url = ServiceUrl.Replace("localhost", EndPoint); var location = cnn.LocationGetByCode(locationCode, GlobalContext.WarehouseCode); if (location == null) { GlobalMessageBox.ShowInfomation("ไม่พบตำแหน่งจัดเก็บสินค้านี้ ในระบบ"); return; } txtLocationCode.Text = location.Code; } else { txtLocationCode.Text = locationCode; } //chkOffline.Enabled = false; txtLocationCode.Enabled = false; txtBarcode.Enabled = true; txtEmployeeCode.Enabled = true; btnSearchUser.Enabled = true; txtBarcode.Focus(); } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private bool ValidateForm() { if (string.IsNullOrEmpty(txtEmployeeName.Text)) { GlobalMessageBox.ShowInfomation("กรุณาเลือกพนักงานประจำล็อก ก่อนทำการบันทึก"); return(false); } if (this.dtChangePrice.Value == null) { GlobalMessageBox.ShowInfomation("กรุณาวันที่ป้ายปรับ ก่อนทำการบันทึก"); return(false); } return(true); }
private void BindGrid() { btnSave.Enabled = false; if (string.IsNullOrEmpty(txtBarcode.Text.Trim())) { GlobalMessageBox.ShowInfomation("กรุณาระบุบาร์โค้ดสินค้า ก่อนทำการค้นหา"); txtBarcode.Focus(); return; } try { Cursor.Current = Cursors.WaitCursor; var barcode = txtBarcode.Text.Trim(); var productBarcode = ServiceHelper.MobileServices.ProductBarcodeGetByBarcode(barcode, GlobalContext.BranchCode); if (productBarcode == null) { return; } else { txtProductCode.Text = productBarcode.ProductCode; txtProductName.Text = productBarcode.ProductName; txtUnitCode.Text = productBarcode.UnitCode; txtUnitName.Text = productBarcode.UnitName; List <ProductLocation> productLocations = new List <ProductLocation>(); var productLocationResult = ServiceHelper.MobileServices.ProductLocationGetAllByBarcode(barcode, GlobalContext.BranchCode, GlobalContext.WarehouseCode); productLocations.AddRange(productLocationResult); if (productLocationResult != null) { bsLocation.DataSource = productLocations; btnSave.Enabled = true; } this.txtBarcode.Text = null; } } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }
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 void btnSave_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; var forklifts = (List <ForkLift>)bindingSourceForklift.DataSource; var forklift = forklifts.Find(p => p.IsSelected); if (forklift != null) { forklift.IsSelected = true; var orderedSet = new OrderedSet(); orderedSet.OrderNo = tbOrderNo.Text.Trim(); orderedSet.ForkliftNumber = forklift.ForkliftNumber; orderedSet.DriverName = forklift.DriverName; orderedSet.CreatedBy = string.Format("{0}:{1}", GlobalContext.UserCode, GlobalContext.UserName); orderedSet.BranchCode = GlobalContext.BranchCode; orderedSet.ShippointCode = GlobalContext.ShippointCode; ServiceHelper.MobileServices.OrderedSetAdd(orderedSet); Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("บันทึกการจ่ายใบจัด เรียบร้อย"); foreach (var item in forklifts) { item.IsSelected = false; } bindingSourceForklift.ResetBindings(false); btnSave.Enabled = false; btnNew_Click(null, null); } else { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowWarnning("กรุณาเลือกรถ เพื่อใช้กับใบจัดนี้"); } } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } //finally //{ // Cursor.Current = Cursors.Default; //} }
private void BindLocationData() { try { Cursor.Current = Cursors.WaitCursor; var locationCode = txtLocationCode.Text.Trim().ToUpper(); if (!OfflineMode) { var EndPoint = GlobalContext.ServerEndpointAddress; var ServiceUrl = GlobalContext.remoteAddress; var cnn = new DoHome.HandHeld.Client.SAPCnn.MobileService(); cnn.Url = ServiceUrl.Replace("localhost", EndPoint); var location = cnn.LocationGetByCode(locationCode, GlobalContext.WarehouseCode); //var location = ServiceHelper.MobileServices.LocationGetByCode(locationCode, GlobalContext.WarehouseCode); ////var isExists = LocationManager.CheckExistsLocation(locationCode); if (location == null) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("ไม่พบตำแหน่งจัดเก็บสินค้านี้ ในระบบ"); return; } if (!CheckIsCreateLocationToday()) { return; } } this.txtLocationCode.Text = locationCode; this.txtLocationCode.Enabled = false; this.txtProductCode.Enabled = true; this.txtEmployeeCode.Enabled = true; this.btnSearchUser.Enabled = true; this.txtProductCode.Focus(); Cursor.Current = Cursors.Default; } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void SaveData() { if (gvLocationProduct.DataSource != null) { try { Cursor.Current = Cursors.WaitCursor; LocationCheckProductManager.TransferToServer(); Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("บันทึกข้อมูลไปยัง Server สำเร็จ"); this.Close(); } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError("บันทึกข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง " + ex.Message); 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 btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUserName.Text)) { GlobalMessageBox.ShowInfomation("กรุณาระบุชื่อเข้าใช้งาน"); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { GlobalMessageBox.ShowInfomation("กรุณาระบุรหัสผ่านเข้าใช้งาน"); return; } if ("0000".Equals(ddlBranch.SelectedValue)) { GlobalMessageBox.ShowInfomation("กรุณาเลือกสาขา"); return; } if ("0000".Equals(ddlWarehouse.SelectedValue)) { GlobalMessageBox.ShowInfomation("กรุณาเลือกคลังสินค้า"); return; } if (ddlUseInPlaces.SelectedIndex == 0) { GlobalMessageBox.ShowInfomation("กรุณาสถานที่ใช้งาน"); return; } try { Cursor.Current = Cursors.WaitCursor; //var user = ServiceHelper.MobileServices.UserCheckLogin(GlobalContext.BranchCode, txtUserName.Text.Trim(), txtPassword.Text.Trim()); var user = UserManager.CheckLogin(txtUserName.Text.Trim(), txtPassword.Text.Trim()); if (user != null) { GlobalContext.UserCode = user.Code; GlobalContext.UserName = user.Name; GlobalContext.IsShowPrice = user.IsShowPrice; GlobalContext.IsShowSaleProfit = user.IsShowSaleProfit; GlobalContext.BranchCode = ddlBranch.SelectedValue.ToString(); GlobalContext.BranchName = ddlBranch.Text; GlobalContext.WarehouseCode = ddlWarehouse.SelectedValue.ToString(); GlobalContext.WarehouseName = ddlWarehouse.Text; if (ddlUseInPlaces.SelectedIndex == 1) { GlobalContext.UseInPlaces = UseInPlaces.STORE; GlobalContext.IsShowPrice = true; } if (ddlUseInPlaces.SelectedIndex == 2) { GlobalContext.UseInPlaces = UseInPlaces.WAREHOUSE; GlobalContext.IsShowPrice = false; } this.Hide(); new MainForm().Show(); } else { GlobalMessageBox.ShowError("ไม่มีพนักงานชื่อนี้ในระบบ หรือ ระบุข้อมูลไม่ถูกต้อง!"); } } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void btnSave_Click(object sender, EventArgs e) { if (IsValidateForm) { var oForm = new CountStockMainSaveForm(); if (oForm.ShowDialog() == DialogResult.OK) { 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. var documentNo = ServiceHelper.MobileServices.AddHandHeldCounterMainHold(GlobalContext.BranchCode, counterHolds); if (oForm.ValueIsMajor) { var majorCounter1 = oForm.ValueMajorCounter1; var majorCounter2 = oForm.ValueMajorCounter2; ServiceHelper.MobileServices.AddMajorHandHeldCounterMainHoldToSap(GlobalContext.BranchCode, documentNo , majorCounter1 , majorCounter2); } else { var officerID1 = oForm.ValueOfficer1; var officerID2 = oForm.ValueOfficer2; var officerID3 = oForm.ValueOfficer3; var officerID4 = oForm.ValueOfficer4; ServiceHelper.MobileServices.AddMinorHandHeldCounterMainHoldToSap(documentNo , officerID1 , officerID2 , officerID3 , officerID4 , GlobalContext.WarehouseCode , GlobalContext.BranchCode); } GlobalMessageBox.ShowInfomation("บันทึกข้อมูลเรียบร้อย"); this.ClearControlBinding(); } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } finally { Cursor.Current = Cursors.Default; } } } }
private void BindGrid() { var barcode = txtBarcode.Text; if (string.IsNullOrEmpty(barcode)) { GlobalMessageBox.ShowInfomation("กรุณาระบุบาร์โค้ดสินค้า ก่อนทำการค้นหา"); txtBarcode.Focus(); return; } else if (barcode.IndexOf(Convert.ToChar(".")) > -1) { // if price no scan. txtBarcode.Text = null; return; } else if (Utils.CheckLocationIsLocation(barcode)) { // if location no scan. txtBarcode.Text = null; return; } try { Cursor.Current = Cursors.WaitCursor; if (bsProductLocation.DataSource == null) { bsProductLocation.DataSource = new List <ProductLocation>(); } ProductLocation productLocation = null; if (!OfflineMode) { var isWarehouse = GlobalContext.UseInPlaces == UseInPlaces.WAREHOUSE ? true : false; productLocation = ServiceHelper.MobileServices.ProductLocationGetByBarcode(txtBarcode.Text.Trim(), txtLocationCode.Text, GlobalContext.WarehouseCode, GlobalContext.BranchCode, isWarehouse); } else { productLocation = new ProductLocation(); productLocation.ProductBarcode = txtBarcode.Text.Trim(); productLocation.StatusText = "Offline"; } if (productLocation != null) { var productLocations = (List <ProductLocation>)bsProductLocation.DataSource; if (productLocations.Find(p => p.ProductBarcode == productLocation.ProductBarcode) != null) { GlobalMessageBox.ShowInfomation("มีสินค้านี้อยู่ในรายการแล้ว"); } else { ((List <ProductLocation>)bsProductLocation.DataSource).Add(productLocation); bsProductLocation.ResetBindings(false); } this.btnSave.Enabled = true; } this.txtBarcode.Text = null; } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtEmployeeName.Text)) { GlobalMessageBox.ShowInfomation("กรุณาเลือกพนักงานประจำล็อก ก่อนทำการบันทึก"); return; } try { Cursor.Current = Cursors.WaitCursor; var productLocations = (List <ProductLocation>)bsProductLocation.DataSource; foreach (var item in productLocations) { item.OfficerID = txtEmployeeCode.Text.Trim(); } if (OfflineMode) { using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString)) { con.Open(); using (SqlCeCommand com = new SqlCeCommand()) { com.Connection = con; IDbTransaction trans = con.BeginTransaction(IsolationLevel.Serializable); try { var locationCode = txtLocationCode.Text.Trim(); com.CommandText = SqlHelper.GetSql(30); com.Parameters.AddWithValue("@LocationCode", locationCode); com.Parameters.AddWithValue("@CreatedBy", GlobalContext.UserCode); com.ExecuteNonQuery(); com.CommandText = SqlHelper.GetSql(31); var displayOrder = 0; foreach (var item in productLocations) { com.Parameters.Clear(); com.Parameters.AddWithValue("@LocationCode", locationCode); com.Parameters.AddWithValue("@BranchCode", GlobalContext.BranchCode); com.Parameters.AddWithValue("@WarehouseCode", GlobalContext.WarehouseCode); com.Parameters.AddWithValue("@DisplayOrder", displayOrder); com.Parameters.AddWithValue("@Barcode", item.ProductBarcode); com.Parameters.AddWithValue("@OfficerId", item.OfficerID); com.Parameters.AddWithValue("@CreatedBy", GlobalContext.UserCode); com.ExecuteNonQuery(); displayOrder++; } trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } } } else { ServiceHelper.MobileServices.ProductLocationMixAdd(GlobalContext.BranchCode, GlobalContext.WarehouseCode, GlobalContext.UserCode, productLocations.ToArray()); } //GlobalMessageBox.ShowInfomation("บันทึกข้อมูลเรียบร้อยแล้ว"); btnClear_Click(sender, e); } catch (Exception ex) { GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }
private bool ValidatePassword() { if (ValueIsMajor) { var officer = ddlMajorCounter1.SelectedValue as string; if (string.IsNullOrEmpty(officer)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ ผู้นับ 1"); return(false); } officer = ddlMajorCounter2.SelectedValue as string; if (string.IsNullOrEmpty(officer)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ ผู้นับ 2"); return(false); } } else { string officer = string.Empty; string password = string.Empty; officer = ddlOfficer1.SelectedValue as string; password = txtPassword1.Text.Trim(); if (string.IsNullOrEmpty(officer)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ พนักงานคลัง 1"); return(false); } else { if (string.IsNullOrEmpty(password)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ รหัสผ่าน พนักงานคลัง 1"); return(false); } else { if (!CheckUserPassword(officer, password)) { GlobalMessageBox.ShowInfomation("รหัสผ่าน พนักงานคลัง 1 ไม่ถูกต้อง"); return(false); } } } officer = ddlOfficer2.SelectedValue as string; password = txtPassword2.Text.Trim(); if (string.IsNullOrEmpty(officer)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ พนักงานคลัง 2"); return(false); } else { if (string.IsNullOrEmpty(password)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ รหัสผ่าน พนักงานคลัง 2"); return(false); } else { if (!CheckUserPassword(officer, password)) { GlobalMessageBox.ShowInfomation("รหัสผ่าน พนักงานคลัง 2 ไม่ถูกต้อง"); return(false); } } } officer = ddlOfficer3.SelectedValue as string; password = txtPassword3.Text.Trim(); if (string.IsNullOrEmpty(officer)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ พนักงานตรวจสอบภายใน"); return(false); } else { if (string.IsNullOrEmpty(password)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ รหัสผ่าน พนักงานตรวจสอบภายใน"); return(false); } else { if (!CheckUserPassword(officer, password)) { GlobalMessageBox.ShowInfomation("รหัสผ่าน พนักงานตรวจสอบภายใน ไม่ถูกต้อง"); return(false); } } } officer = ddlOfficer4.SelectedValue as string; password = txtPassword4.Text.Trim(); if (string.IsNullOrEmpty(officer)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ หัวหน้าโซน"); return(false); } else { if (string.IsNullOrEmpty(password)) { GlobalMessageBox.ShowInfomation("กรุณาระบุ รหัสผ่าน หัวหน้าโซน"); return(false); } else { if (!CheckUserPassword(officer, password)) { GlobalMessageBox.ShowInfomation("รหัสผ่าน หัวหน้าโซน ไม่ถูกต้อง"); return(false); } } } } return(true); }
private void SaveData() { if (gvLocationProduct.DataSource != null) { Cursor.Current = Cursors.WaitCursor; DataTable data = (DataTable)gvLocationProduct.DataSource; var id = 0; var locationCode = string.Empty; foreach (DataRow item in data.Rows) { id = Convert.ToInt32(item["Id"]); locationCode = item["LocationCode"].ToString(); DataTable locationProduct = new DataTable(); using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString)) { con.Open(); using (SqlCeCommand com = new SqlCeCommand(SqlHelper.GetSql(52), con)) { com.Parameters.AddWithValue("@Id", id); using (SqlCeDataAdapter adap = new SqlCeDataAdapter(com)) { adap.Fill(locationProduct); } } } List <ProductLocation> productLocations = new List <ProductLocation>(); foreach (DataRow row in locationProduct.Rows) { productLocations.Add(new ProductLocation { //LocationCode = locationCode, LocationType = Utils.GetLocationTypeByLocationCode(locationCode), ProductBarcode = row["ProductCode"].ToString(), //WarehouseCode = GlobalContext.WarehouseCode, PutQuantity = Utils.DecimalParse(row["PutQty"].ToString()), PutQuantitySpecified = true, PutLevel = Utils.DecimalParse(row["PutLevel"].ToString()), PutLevelSpecified = true, DisplayOrder = Utils.Int32Parse(row["DisplayOrder"].ToString()), DisplayOrderSpecified = true, RequestPrintLabel = Convert.IsDBNull(row["RequestPrintLabel"]) ? false : Convert.ToBoolean(row["RequestPrintLabel"]), RequestPrintLabelSpecified = true, MaxStock = Utils.DecimalParse(row["MaxStock"].ToString()), MaxStockSpecified = true, UserID = GlobalContext.UserCode, Remark = row["PrintLabelType"].ToString() }); } var result = string.Empty; result = ServiceHelper.MobileServices.ProductLocationAdd(GlobalContext.BranchCode, locationCode, GlobalContext.WarehouseCode, productLocations.ToArray()); if (!"ERROR".Equals(result)) { Delete(id); //using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString)) //{ // con.Open(); // using (SqlCeCommand com = new SqlCeCommand(SqlHelper.GetSql(51), con)) // { // com.Parameters.AddWithValue("@Id", id); // com.ExecuteNonQuery(); // } //} } else { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError("บันทึกข้อมูลไม่สำเร็จ กรุณาติดต่อผู้ดูแล"); BindGrid(); return; } } Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("บันทึกข้อมูลไปยัง SAP สำเร็จ"); BindGrid(); } }
private void BindGrid() { //lblMessage.Visible = false; string messageAlert = string.Empty; try { Cursor.Current = Cursors.WaitCursor; List <HandHeldCounterHold> prouductBarcode = null; if (bindingSource.DataSource == null) { bindingSource.DataSource = new List <HandHeldCounterHold>(); } prouductBarcode = (List <HandHeldCounterHold>)bindingSource.DataSource; var productCodeOrBarcode = txtScan.Text.Trim(); //MessageBox.Show("MobileServices.GetProductCode"); var productCode = ServiceHelper.MobileServices.GetProductCode(GlobalContext.BranchCode, productCodeOrBarcode); //MessageBox.Show(productCode); if (prouductBarcode.FindAll(p => p.Productcode == productCode).Count > 0) { GlobalMessageBox.ShowInfomation("มีสินค้าอยู่ในรายการตรวจสอบนี้แล้ว"); //clear barcode textbox this.txtScan.Text = string.Empty; this.txtScan.Focus(); return; } //MessageBox.Show("call HandHeldCounterHoldGetByProductCode"); var products = ServiceHelper.MobileServices.HandHeldCounterHoldGetByProductCode(productCode , GlobalContext.UserCode , GlobalContext.UserCode//ddlEmployee.SelectedValue as string , GlobalContext.WarehouseCode , GlobalContext.BranchCode , out messageAlert); //MessageBox.Show(products.Length.ToString ()); //test. //ServiceHelper.MobileServices.HandHeldCounterHoldGetByProductCode2(productCode // , GlobalContext.UserCode // , ddlEmployee.SelectedValue as string // , GlobalContext.WarehouseCode // , GlobalContext.BranchCode); if (products != null) { foreach (var item in products) { prouductBarcode.Add(item); } bindingSource.DataSource = prouductBarcode; bindingSource.ResetBindings(false); } else { if (string.IsNullOrEmpty(messageAlert)) { GlobalMessageBox.ShowInfomation("ไม่พบรหัสสินค้า/บาร์โค้ดที่ระบุ"); } else { GlobalMessageBox.ShowInfomation(messageAlert); } } //clear barcode textbox this.txtScan.Text = string.Empty; this.txtScan.Focus(); } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError(ex); } finally { Cursor.Current = Cursors.Default; } }
private void tbOrderNoFinish_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { Cursor.Current = Cursors.WaitCursor; var barcode = tbOrderNoFinish.Text.Trim(); if (string.IsNullOrEmpty(barcode)) { barcode = CeReader.Barcode.Scan(); } //if (!RF1DHelper.Scan(out barcode)) // barcode = tbOrderNoFinish.Text.Trim(); if (string.IsNullOrEmpty(barcode)) { GlobalMessageBox.ShowWarnning("กรุณาระบุเลขที่เอกสาร"); return; } else { if (barcode.Length > 10) { barcode = barcode.Substring(0, 10); } tbOrderNoFinish.Text = barcode; var order = ServiceHelper.MobileServices.OrderedSetGetByOrderNo(barcode); if (order != null) { if (order.FinishOn == null) { ServiceHelper.MobileServices.OrderedSetUpdate(barcode); tbOrderNoFinish.Text = barcode; GlobalMessageBox.ShowInfomation(string.Format("ปิดใบจัดเลขที่\n{0}\nเรียบร้อยแล้ว", barcode)); //tbOrderNoFinish.Text = string.Empty; //tbOrderNoFinish.Focus(); } else { new OrderedInfoForm(order).ShowDialog(); } this.Close(); } else { GlobalMessageBox.ShowWarnning("ไม่พบเลขที่เอกสารนี้ ในระบบ"); } } } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } finally { Cursor.Current = Cursors.Default; } } }
private void btnSave_Click(object sender, EventArgs e) { if (_labelPrice.Count <= 0) { GlobalMessageBox.ShowInfomation("ระบุสินค้าก่อนทำการบันทึก"); return; } if (string.IsNullOrEmpty(cmbPrintType.Text)) { GlobalMessageBox.ShowInfomation("กรุณาเลือกประเภทป้าย"); return; } Cursor.Current = Cursors.WaitCursor; //var list = new List<LabelPrintProductDetail>(); //foreach (var item in _labelPrice) //{ // var labelPrice = new LabelPrintProductDetail(); // labelPrice.Productcode = product.ProductCode; // labelPrice.Productname = product.ProductName; // labelPrice.Barcode = product.Barcode; // labelPrice.Unitcode = product.UnitCode; // labelPrice.Unitname = product.UnitName; // labelPrice.OthUnitcode = labelPrice.Unitcode; // labelPrice.OthUnitname = labelPrice.Unitname; // labelPrice.PrintLabelTypeCode = cmbPrintType.Text; // var productPrice = MobileServiceHelper.MobileService.ProductPriceGetCurrentPrice(LabelPriceSession.Current.BranchCode, labelPrice.Productcode, labelPrice.Unitcode); // if (productPrice != null) // { // labelPrice.Sellprice = productPrice.Saleprice; // labelPrice.Pricedate = productPrice.Begindate; // labelPrice.OthUnitprice = labelPrice.Sellprice; // } // labelPrice.DisplayOrder = LabelPriceSession.Current.LabelPrintProductDetails.Count + 1; // LabelPriceSession.Current.LabelPrintProductDetails.Add(labelPrice); // list.Add(new LabelPrintProductDetail() { LocationCode = item.LocationCode }); //} try { var _labelPriceL = new List <LabelPrintProductDetail>(); foreach (var item in _labelPrice) { var labelPrice = new LabelPrintProductDetail(); labelPrice.Productcode = item.Productcode; labelPrice.Productname = item.Productname; labelPrice.Barcode = item.Barcode; labelPrice.Unitcode = item.Unitcode; labelPrice.Unitname = item.Unitname; labelPrice.OthUnitcode = labelPrice.Unitcode; labelPrice.OthUnitname = labelPrice.Unitname; labelPrice.PrintLabelTypeCode = cmbPrintType.SelectedValue.ToString(); var productPrice = ServiceHelper.MobileServices.ProductPriceGetCurrentPrice(GlobalContext.BranchCode, labelPrice.Productcode, labelPrice.Unitcode); if (productPrice != null) { labelPrice.Sellprice = productPrice.Saleprice; labelPrice.Pricedate = productPrice.Begindate; var productOtherPrice = ServiceHelper.MobileServices.ProductPriceGetCurrentPrice(GlobalContext.BranchCode, labelPrice.Productcode, labelPrice.OthUnitcode); if (productOtherPrice != null) { labelPrice.OthUnitprice = productOtherPrice.Saleprice; } } labelPrice.Sellprice = item.Sellprice; labelPrice.OthUnitprice = labelPrice.Sellprice; labelPrice.Locationcode = ""; labelPrice.Locationname = item.ProductPosition; labelPrice.Producttype = item.ProductLoggr; //labelPrice.s labelPrice.DisplayOrder = _labelPrice.Count + 1; labelPrice.DisplayOrderSpecified = true; _labelPriceL.Add(labelPrice); } var docno = ServiceHelper.MobileServices.LabelPrintProductAddWithDetail(GlobalContext.BranchCode , GlobalContext.UserCode , string.Format("Request from PDA by {0}", GlobalContext.UserCode) , cmbPrintType.SelectedValue.ToString() , _labelPriceL.ToArray()); _labelPrice.Clear(); grdLocations.DataSource = null; Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation(string.Format("บันทึกข้อมูล เสร็จเรียบร้อยแล้ว\nเลขที่เอกสารที่ได้คือ\n{0}", docno)); tbBarcode.Text = null; tbBarcode.Focus(); } catch (Exception ex) { GlobalMessageBox.ShowError(ex); } }
private void AddOffLineMode() { var productLocations = (List <ProductLocation>)bsLocation.DataSource; if (productLocations.Exists(p => p.RequestPrintLabel) && cmbLabelType.SelectedIndex == 0) { GlobalMessageBox.ShowInfomation("กรุณาเลือกประเภทป้าย\nก่อนบันทึกข้อมูล"); return; } try { Cursor.Current = Cursors.WaitCursor; this.PrepareSave(); productLocations = (List <ProductLocation>)bsLocation.DataSource; using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString)) { con.Open(); using (SqlCeCommand cmd = new SqlCeCommand()) { cmd.Connection = con; IDbTransaction trans = con.BeginTransaction(IsolationLevel.Serializable); try { var locationCode = txtLocationCodeScan.Text.Trim(); cmd.CommandType = CommandType.Text; cmd.CommandText = SqlHelper.GetSql(48); cmd.Parameters.AddWithValue("@LocationCode", locationCode); cmd.Parameters.AddWithValue("@UserCode", GlobalContext.UserCode); cmd.ExecuteScalar(); cmd.Parameters.Clear(); //get the last insert id cmd.CommandText = "SELECT @@IDENTITY"; int id = Convert.ToInt32(cmd.ExecuteScalar()); cmd.CommandText = SqlHelper.GetSql(49); var displayOrder = 1; foreach (var item in productLocations) { //com.Parameters.AddWithValue("@LocationCode", locationCode); cmd.Parameters.AddWithValue("@LocationId", id); cmd.Parameters.AddWithValue("@ProductCode", item.ProductCode); cmd.Parameters.AddWithValue("@PutLevel", item.PutLevel); cmd.Parameters.AddWithValue("@PutQty", item.PutQuantity); cmd.Parameters.AddWithValue("@DisplayOrder", displayOrder); //com.Parameters.AddWithValue("@UserCode", GlobalContext.UserCode); cmd.Parameters.AddWithValue("@RequestPrintLabel", item.RequestPrintLabel); cmd.Parameters.AddWithValue("@MaxStock", item.MaxStock); if (item.Remark.Contains("เลือก")) { item.Remark = string.Empty; } cmd.Parameters.AddWithValue("@PrintLabelType", item.Remark); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); displayOrder++; } trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } } //GlobalMessageBox.ShowInfomation("บันทึกข้อมูลผูกตำแหน่งเรียบร้อย\n[Offline Mode] "); // call btnClear button btnClear_Click(null, null); } catch (Exception ex) { MessageBox.Show(ex.Message, "พบข้อผิดพลาด"); } finally { Cursor.Current = Cursors.Default; } }
private void SaveData() { if (gvLocationProduct.DataSource != null) { try { Cursor.Current = Cursors.WaitCursor; //LocationCheckProductManager.TransferToServer(); DataTable productMixedTable = new DataTable(); List <ProductLocation> productLocations = new List <ProductLocation>(); using (SqlCeConnection con = new SqlCeConnection(SqlHelper.SqlCeConnectionString)) { con.Open(); using (SqlCeCommand com = new SqlCeCommand()) { com.Connection = con; foreach (Resco.Controls.SmartGrid.Row item in gvLocationProduct.Rows) { var locationCode = ((System.Data.DataRowView)(item.Data)).Row.ItemArray[0].ToString(); using (SqlCeDataAdapter adab = new SqlCeDataAdapter(com)) { com.CommandText = SqlHelper.GetSql(33); com.Parameters.Clear(); com.Parameters.AddWithValue("@LocationCode", locationCode); com.Parameters.AddWithValue("@CreatedBy", GlobalContext.UserCode); adab.Fill(productMixedTable); var isWarehouse = GlobalContext.UseInPlaces == UseInPlaces.WAREHOUSE ? true : false; foreach (DataRow row in productMixedTable.Rows) { var productLocation = ServiceHelper.MobileServices.ProductLocationGetByBarcode(row["Barcode"].ToString(), locationCode, GlobalContext.WarehouseCode, GlobalContext.BranchCode, isWarehouse); productLocation.OfficerID = row["OfficerId"].ToString(); productLocations.Add(productLocation); } // transfer to server. ServiceHelper.MobileServices.ProductLocationMixAdd(GlobalContext.BranchCode, GlobalContext.WarehouseCode, GlobalContext.UserCode, productLocations.ToArray()); //delete com.CommandText = SqlHelper.GetSql(30); com.ExecuteNonQuery(); productMixedTable.Clear(); productLocations.Clear(); } } } } Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("บันทึกข้อมูลไปยัง SAP สำเร็จ"); this.Close(); } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError("บันทึกข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง " + ex.Message); BindGrid(); } } }
private void BindGrid() { if (string.IsNullOrEmpty(txtProductCode.Text.Trim())) { GlobalMessageBox.ShowInfomation("กรุณาระบุบาร์โค้ดสินค้า ก่อนทำการค้นหา"); // GlobalMessageBox.ShowInfomation("กรุณาระบุรหัสสินค้า ก่อนทำการค้นหา"); txtProductCode.Focus(); return; } try { Cursor.Current = Cursors.WaitCursor; if (bsProductLocation.DataSource == null) { bsProductLocation.DataSource = new List <ProductLocation>(); } ProductLocation product = null; var barcode = txtProductCode.Text.Trim(); if (OfflineMode) { product = new ProductLocation(); product.ProductCode = string.Empty; product.ProductBarcode = barcode; product.SalePrice = 0; } else { product = ServiceHelper.MobileServices.ProductLocationGetByProductCodeOrBarcode(barcode, GlobalContext.WarehouseCode, GlobalContext.BranchCode); } if (product != null) { product.ShopPrice = 0; Cursor.Current = Cursors.Default; //กรณีที่ใช้ในคลังหรือตรวจตำแหน่ง Top ไม่ต้องให้แสดงราคา และหน้าจอสำหรับป้อนราคา if (GlobalContext.UseInPlaces == UseInPlaces.WAREHOUSE || Utils.CheckLocationIsTopLevel(txtLocationCode.Text)) { dgvProducts.Columns["columnSalePrice"].Width = 0; dgvProducts.Columns["columnSalePrice"].AutoSizeColumnMode = AutoSizeColumnMode.None; dgvProducts.Columns["columnShopPrice"].Width = 0; dgvProducts.Columns["columnShopPrice"].AutoSizeColumnMode = AutoSizeColumnMode.None; } else { var oForm = new EnterPriceForm(); oForm.ProductCode = product.ProductCode; if (oForm.ShowDialog() == DialogResult.OK) { product.ShopPrice = oForm.Price; if (!OfflineMode) { product.ProductUnitCode = oForm.UnitCode; product.ProductUnitName = oForm.UnitName; var productPrice = ServiceHelper.MobileServices.ProductPriceGetCurrentPrice(GlobalContext.BranchCode, product.ProductCode, product.ProductUnitCode); product.SalePrice = productPrice.Saleprice; } } else { return; } } product.DisplayOrder = ((List <ProductLocation>)bsProductLocation.DataSource).Count + 1; ((List <ProductLocation>)bsProductLocation.DataSource).Add(product); bsProductLocation.ResetBindings(false); this.btnSave.Enabled = true; } this.txtProductCode.Text = null; } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError(ex.Message); } finally { Cursor.Current = Cursors.Default; } }