public void AddPanel(Param.Screen screen) { switch (screen) { case Param.Screen.Sale: if (_UC_SALE == null) { _UC_SALE = new UcSale(); } _USER_CONTROL = _UC_SALE; _UC_SALE.LoadData(); break; case Param.Screen.ReceiveProduct: if (_UC_RECEIVE_PRODUCT == null) { _UC_RECEIVE_PRODUCT = new UcReceiveProduct(); } _USER_CONTROL = _UC_RECEIVE_PRODUCT; _UC_RECEIVE_PRODUCT._FIRST_LOAD = true; _UC_RECEIVE_PRODUCT.LoadData(); _UC_RECEIVE_PRODUCT.SearchData(); break; case Param.Screen.Stock: if (_UC_STOCK == null) { _UC_STOCK = new UcStock(); } _USER_CONTROL = _UC_STOCK; _UC_STOCK.LoadData(); break; case Param.Screen.Product: if (_UC_PRODUCT == null) { _UC_PRODUCT = new UcProduct(); } _USER_CONTROL = _UC_PRODUCT; _UC_PRODUCT._FIRST_LOAD = true; _UC_PRODUCT.LoadData(); break; case Param.Screen.Customer: if (_UC_CUSTOMER == null) { _UC_CUSTOMER = new UcCustomer(); } _USER_CONTROL = _UC_CUSTOMER; _UC_CUSTOMER.LoadData(); break; case Param.Screen.Report: if (_UC_REPORT == null) { _UC_REPORT = new UcReport(); } _USER_CONTROL = _UC_REPORT; _UC_REPORT.LoadData(); break; case Param.Screen.Config: if (_UC_CONFIG == null) { _UC_CONFIG = new UcConfig(); } _USER_CONTROL = _UC_CONFIG; _UC_CONFIG.LoadData(); break; case Param.Screen.Claim: if (Param.shopClaim == true) { if (_UC_CLAIM == null) { _UC_CLAIM = new UcClaim(); } _USER_CONTROL = _UC_CLAIM; } else { if (_UC_DATA_CLAIM == null) { _UC_DATA_CLAIM = new UcAddDataClaim(); } _USER_CONTROL = _UC_DATA_CLAIM; } break; //case Param.Screen.Claim: // if (_UC_DATA_CLAIM == null) _UC_DATA_CLAIM = new UcAddDataClaim(); // _USER_CONTROL = _UC_DATA_CLAIM; // break; case Param.Screen.ReportStock: if (_UC_REPORT_STOCK == null) { _UC_REPORT_STOCK = new UcReportStock(); } _USER_CONTROL = _UC_REPORT_STOCK; break; case Param.Screen.Credit: if (_UC_CREDIT == null) { _UC_CREDIT = new UcCredit(); } _USER_CONTROL = _UC_CREDIT; _UC_CREDIT.LoadData(); break; case Param.Screen.ReportProduct: if (_UC_REPORT_PORDUCT == null) { _UC_REPORT_PORDUCT = new UcReportProduct(); } _USER_CONTROL = _UC_REPORT_PORDUCT; _UC_REPORT_PORDUCT.LoadData(); break; case Param.Screen.claimShop: if (_UC_CLAIM_SHOP == null) { _UC_CLAIM_SHOP = new UcClaimShop(); } _USER_CONTROL = _UC_CLAIM_SHOP; _UC_CLAIM_SHOP.LoadData(); break; case Param.Screen.claimReceived: if (_UC_CLAIM_RECEIVED == null) { _UC_CLAIM_RECEIVED = new UcClaimReceived(); } _USER_CONTROL = _UC_CLAIM_RECEIVED; break; } if (!pnlMain.Contains(_USER_CONTROL)) { pnlMain.Controls.Clear(); _USER_CONTROL.Dock = DockStyle.Fill; pnlMain.Controls.Add(_USER_CONTROL); } }
private void txtBarcode_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) { Param.BarcodeNo = txtBarcode.Text; DataTable dt = Util.DBQuery(string.Format(@"SELECT b.shop, OrderNo, p.product, IFNULL(ReceivedDate, '') ReceivedDate , p.Image FROM BarcodeClaim b LEFT JOIN Product p ON b.product = p.product WHERE b.Barcode = '{0}'", txtBarcode.Text)); //lblStatus.Visible = true; OrderNo = cbbOrderNo.SelectedItem.ToString(); if (dt.Rows.Count == 0) { SoundPlayer simpleSound = new SoundPlayer(@"Resources/Sound/ohno.wav"); simpleSound.Play(); if (txtBarcode.Text == "") { MessageBox.Show("กรุณากรอกบาร์โค้ด ที่ต้องการทำการรับสินค้าเข้า", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("ไม่พบข้อมูลสินค้าชิ้นนี้ในระบบ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { Param.ProductId = dt.Rows[0]["product"].ToString(); _PRODUCT = Param.ProductId; string[] _SHOP = cbbOrderNo.SelectedItem.ToString().Split('/'); if (_SHOP[0].ToString() != dt.Rows[0]["OrderNo"].ToString()) { cbbOrderNo.EditValue = dt.Rows[0]["OrderNo"].ToString() + "/" + dt.Rows[0]["shop"].ToString(); } if (dt.Rows[0]["ReceivedDate"].ToString() != "") { SoundPlayer simpleSound = new SoundPlayer(@"Resources/Sound/ah.wav"); simpleSound.Play(); MessageBox.Show("เคยรับสินค้าชิ้นนี้เข้าระบบแล้ว", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); SearchData(); ptbProduct.Visible = true; ptbProduct.Image = null; int rowHandle = receivedGridView.LocateByValue("ID", _PRODUCT); if (rowHandle != DevExpress.XtraGrid.GridControl.InvalidRowHandle) { receivedGridView.FocusedRowHandle = rowHandle; } var filename = @"Resource/Images/Product/" + _PRODUCT + ".jpg"; _STREAM_IMAGE_URL = Param.ImagePath + "/" + receivedGridView.GetRowCellDisplayText(receivedGridView.FocusedRowHandle, receivedGridView.Columns["Sku"]) + "/" + dt.Rows[0]["Image"].ToString().Split(',')[0]; if (!File.Exists(filename)) { if (dt.Rows[0]["Image"].ToString() != "") { DownloadImage(_STREAM_IMAGE_URL, @"Resource/Images/Product/", _PRODUCT + ".jpg"); } } else { try { ptbProduct.Image = Image.FromFile(filename); } catch { if (dt.Rows[0]["Image"].ToString() != "") { DownloadImage(_STREAM_IMAGE_URL, @"Resource/Images/Product/", _PRODUCT + ".jpg"); } } } } else { Util.DBExecute(string.Format(@"UPDATE BarcodeClaim SET ReceivedDate = STRFTIME('%Y-%m-%d %H:%M:%S', 'NOW'), ReceivedBy = '{1}', sync = 1 WHERE Barcode = '{0}'", txtBarcode.Text, Param.UserId)); _PRODUCT = Param.ProductId; SearchData(); SoundPlayer simpleSound = new SoundPlayer(@"Resources/Sound/fastpop.wav"); simpleSound.Play(); lblStatus.ForeColor = Color.Green; lblStatus.Text = "รับสินค้าเข้าระบบเรียบร้อยแล้ว"; ptbProduct.Visible = true; ptbProduct.Image = null; int rowHandle = receivedGridView.LocateByValue("ID", _PRODUCT); if (rowHandle != DevExpress.XtraGrid.GridControl.InvalidRowHandle) { receivedGridView.FocusedRowHandle = rowHandle; } var filename = @"Resource/Images/Product/" + _PRODUCT + ".jpg"; _STREAM_IMAGE_URL = Param.ImagePath + "/" + receivedGridView.GetRowCellDisplayText(receivedGridView.FocusedRowHandle, receivedGridView.Columns["Sku"]) + "/" + dt.Rows[0]["Image"].ToString().Split(',')[0]; if (!File.Exists(filename)) { if (dt.Rows[0]["Image"].ToString() != "") { DownloadImage(_STREAM_IMAGE_URL, @"Resource/Images/Product/", _PRODUCT + ".jpg"); } } else { try { ptbProduct.Image = Image.FromFile(filename); } catch { if (dt.Rows[0]["Image"].ToString() != "") { DownloadImage(_STREAM_IMAGE_URL, @"Resource/Images/Product/", _PRODUCT + ".jpg"); } } } } } if (lblNoReceived.Text == "0 ชิ้น") { if (cbbOrderNo.SelectedIndex != 0) { SoundPlayer simpleSound = new SoundPlayer(@"Resources/Sound/yahoo.wav"); simpleSound.Play(); } } txtBarcode.Text = ""; txtBarcode.Focus(); _UC_CLAIM_SHOP = new UcClaimShop(); _UC_CLAIM_SHOP.LoadData(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }