public static void LoadDanhMucSKU() { try { if (CheckFileINVMST()) { try { SplashScreen.SetCommentaryString("Load Danh mục ......."); TPSDataAccess access = new TPSDataAccess(@"C:\WINDOWS\Temp\INVMST.tps"); _tableDMSKU = access.GetDataTable("Select SKU,UPC,DESCRIPTION from INVMST where CONF_PRICE='N' and UPC<>''"); //_tableDMSKU.Columns.Add("GhiChu"); } catch (Exception e) { CTLError.WriteError("GetDMSKU config GetConfiguration", e.Message); } } } catch (Exception e) { CTLError.WriteError("LoadDanhMucSKU config GetConfiguration", e.Message); return; throw; } }
private void button1_Click(object sender, EventArgs e) { TPSDataAccess acces = new TPSDataAccess(@"D:\WinDSS\Data\INVEVT.tps"); DataTable dt = new DataTable(); dt = acces.GetDataTable("Select * from INVEVT where Method=25 and Stop>=108847 and Stop<=109211"); GridDSMa.DataSource = dt; }
private void FrmCheckGia_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5) { if (txtsku.Text != string.Empty) { string masku = txtsku.Text; if (txtsku.Text.Length <= 7) { masku = "00" + txtsku.Text; } else if (txtsku.Text.Length > 9) { if (txtsku.Text.Length <= 14) { masku = GetSKU(PhatSinhUPC.Substring(0, 18 - txtsku.Text.Length) + txtsku.Text); } else { masku = GetSKU(txtsku.Text); } } TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, this._pathFileDM)); DataTable dt = access.GetDataTable("Select SKU,Description,Price from INVMST where 1=1" + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + masku + "'")); if (dt.Rows.Count > 0) { _sku = dt.Rows[0]["SKU"].ToString(); labten.Text = dt.Rows[0]["Description"].ToString(); labgia.Text = Convert.ToDecimal(dt.Rows[0]["PRICE"]).ToString("N2") + " VND"; LoadPromo(_sku); } else { _sku = ""; //labten.Text = "_ _"; //labgia.Text = "_ _"; //labslpos.Text = "0"; //labgiapos.Text = "_ _"; //labslKMTL.Text = "0"; //labGiaKMTL.Text = "_ _"; //gridControl1.DataSource = null; } } else { labten.Text = "_ _"; labgia.Text = "_ _"; labslpos.Text = "0"; labgiapos.Text = "_ _"; labslKMTL.Text = "0"; labGiaKMTL.Text = "_ _"; // gridControl1.DataSource = null; return; } } }
private void BTcheckFileT_Click(object sender, EventArgs e) { if (validateForm()) { try { panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; TPSDataAccess accessPathWSS = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, "SYSMST")); string MaST = "0"; MaST = accessPathWSS.getMaSieuthi(); if (MaST == "0") { InfoMessage.HienThi("Khong lay Duoc Store ...,Vui long lien he voi Admin", "Loi ", "Thong bao", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } NetworkShareAccesser.Access("10.10.1.23", "synback", "synsgcoop"); string strStore = "000" + MaST; strStore = strStore.Substring(strStore.Length - 5, 5); _Store = strStore; FileInfo f = new FileInfo(@"\\10.10.1.23\QDLS\MM770FLR\" + "A" + strStore + @"\T1" + Ngay.Value.ToString("dd") + ".001"); FileInfo fthumuc0 = new FileInfo(@"\\10.10.1.23\QDLS\MM770FLR\" + strStore + @"\T1" + Ngay.Value.ToString("yyMMdd") + ".001"); DateTime datemodify = f.LastWriteTime; if (f.Exists && datemodify.Month == Ngay.Value.Month) { panel2.Visible = true; } else if (fthumuc0.Exists) { panel1.Visible = true; } else { panel3.Visible = true; } } catch (Exception) { throw; } } }
private void BTLoadDS_Click(object sender, EventArgs e) { WaitingMsg waitingMsg = new WaitingMsg("Chương trình đang load dữ liệu!", "Please Waiting ......."); try { if (CopyFileINVMST()) { if (_PathFileINVMST == string.Empty) { InfoMessage.HienThi("Thong bao", "Không lấy đữ liệu được ! Vui lòng kiểm tra lại H:\\ hoặc Server 21", "Lay du lieu khong thanh cong", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } //_PathFileINVMST = @"C:\WINDOWS\Temp\INVMST.tps"; TPSDataAccess access = new TPSDataAccess(_PathFileINVMST); string strsql = string.Format(@"Select SKU,Description,Disc_Flag,0 as Check from INVMST where Disc_Flag='N'"); DataTable dt = new DataTable(); dt = access.GetDataTable(strsql); GrDSPriceSKU.DataSource = null; if (dt != null && dt.Rows.Count > 0) { GrDSPriceSKU.DataSource = dt; repositoryItemCheckEdit2.ValueChecked = 1; repositoryItemCheckEdit2.ValueUnchecked = 0; } } else { InfoMessage.HienThi("Thong bao", "Không lấy đữ liệu được ! Vui lòng kiểm tra lại H:\\ hoặc Server 21", "Lay du lieu khong thanh cong", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } waitingMsg.Finish(); } catch (Exception exception) { CTLError.WriteError("btLoadData ", exception.Message); waitingMsg.Finish(); return; } }
public bool LoadForm(string sku) { try { TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, @"INVMST.tps")); DataTable dtinv = access.GetDataTable(string.Format(@"select SKU,PRICE,Description,UPC from INVMST Where SKU='{0}'", sku)); if (dtinv != null && dtinv.Rows.Count > 0) { labsku.Text = dtinv.Rows[0]["SKU"].ToString(); labUPC.Text = dtinv.Rows[0]["UPC"].ToString(); labname.Text = dtinv.Rows[0]["Description"].ToString(); labGiagoc.Text = Convert.ToDecimal(dtinv.Rows[0]["Price"]).ToString("N0"); LoadPromotion(sku); } return(true); } catch (Exception ex) { CTLError.WriteError("FrmThongTinKMOfSKU FrmThongTinKMOfSKU ", ex.Message); return(false); } }
private void MainForm_MdiChildActivate(object sender, EventArgs e) { if (frmLogIn.Visible) { barControl.Hide(); barControl.Enabled = false; } if (!frmLogIn.Visible) { barControl.Enabled = true; barControl.Show(); txtLogIn.Caption = "Xin chào " + frmLogIn.MaNV + " - " + frmLogIn.MaST; Config._idcreate = frmLogIn.ID; Config._tennv = frmLogIn.TenNV; Config._tenst = frmLogIn.MaST; Config._MaNV = frmLogIn.ID; TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, "SYSMST")); string MaST = "0"; MaST = access.getMaSieuthi(); storename.Caption = " WinDSS Store number: " + MaST; //XetQuyenNhanVien(frmLogIn.ID, frmLogIn.TenNV); XetQuyenNhanVien(frmLogIn.ID); } }
private void txtsoluong_KeyDown(object sender, KeyEventArgs e) { string upc = ""; string sku = ""; if (e.KeyCode == Keys.F5) { btclear_Click(null, null); return; } if (e.KeyCode == Keys.Enter) { if (gridView1.RowCount >= 30) { InfoMessage.HienThi("Số lượng SKU cho phép xuất bảng giá là 30 !", "Vui lòng kiểm tra lại", "Thong bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } if (txtSKU.Text == string.Empty || txtSKU.Text.Length > 18) { return; } string where = ""; if (txtSKU.Text.Length <= 9) { sku = _sokhong.Substring(0, 9 - txtSKU.Text.Length) + txtSKU.Text; where = " and SKU='" + sku + "'"; } else { upc = _sokhong.Substring(0, 18 - txtSKU.Text.Length) + txtSKU.Text; where = " and UPC='" + upc + "'"; } if (!validate((sku != string.Empty) ? sku : upc)) { InfoMessage.HienThi("SKU đã có trong danh sách!", "Vui lòng thay đổi số lượng trong lưới", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } TPSDataAccess dataAccess = new TPSDataAccess(_PathFileINVMST); TPSDataAccess dataAccessKM = new TPSDataAccess(_PathFileINVEVT); DataTable dt = new DataTable(); dt = dataAccess.GetTableDM("Select SKU,UPC,Description,Price From INVMST where 1=1 " + where); if (dt == null || dt.Rows.Count <= 0) { InfoMessage.HienThi("SKU không có trong danh mục!", "Vui lòng kiểm tra lại", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } DataTable dtKM = new DataTable(); dtKM = dataAccessKM.GetTableDM("select SKU,QTY1,PRICE,DISCPRICE,Method,Prc_Key,Code From INVEVT where SKU='" + dt.Rows[0]["SKU"].ToString() + "' and " + (Math.Round(dateNgayapDung.Value.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(dateNgayapDung.Value.ToOADate()) + _Const_datetime) + " <= stop and Method in (2,25)"); DataRow r = _dsSKU.NewRow(); r["SKU"] = dt.Rows[0]["SKU"].ToString(); r["UPC"] = dt.Rows[0]["UPC"].ToString(); r["Description"] = dt.Rows[0]["Description"].ToString(); r["SoLuong"] = txtsoluong.Value; r["GiaGoc"] = dt.Rows[0]["Price"].ToString(); r["ThanhTien"] = r["GiaGoc"]; if (dtKM.Rows.Count > 0) { r["Method"] = dtKM.Rows[0]["Method"].ToString(); r["DISCPRICE"] = dtKM.Rows[0]["DISCPRICE"].ToString(); r["QTY1"] = dtKM.Rows[0]["QTY1"].ToString(); if (dtKM.Rows[0]["Method"].ToString() == "25") { DataRow row; if (dtKM.Select("MeThod=25 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dtKM.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dtKM.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dtKM.Select("MeThod=25 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel1.Visible = true; //labgiapos.Text = " " + Convert.ToDecimal(row["Price"]).ToString("N2");// +" Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslpos.Text = "1"; r["GiaKM"] = row["PRICE"].ToString(); r["ThanhTien"] = txtsoluong.Value * Convert.ToDecimal(r["GiaKM"]); } else if (dtKM.Rows[0]["Method"].ToString() == "2") { DataRow row; if (dtKM.Select("MeThod=2 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dtKM.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dtKM.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dtKM.Select("MeThod=2 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; //labGiaKMTL.Text = "Khi mua với SL " + Convert.ToInt32(row["Qty1"]).ToString("N0") + " giá tiền là " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2"); //+ " Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); r["ThanhTien"] = (int)(txtsoluong.Value / Int32.Parse(Convert.ToDecimal(row["QTY1"]).ToString("N0"))) * Convert.ToDecimal(row["DISCPRICE"].ToString()) + (int)(txtsoluong.Value % Int32.Parse(Convert.ToDecimal(row["QTY1"]).ToString("N0"))) * Convert.ToDecimal(r["GiaGoc"]); r["GhiChu"] = "Mua SL " + row["QTY1"].ToString() + " co gia " + Convert.ToDecimal(row["DISCPRICE"]).ToString("N0"); } } else { r["GiaKM"] = r["GiaGoc"]; r["ThanhTien"] = Convert.ToDecimal(r["GiaGoc"]) * txtsoluong.Value; } _dsSKU.Rows.Add(r); _dsSKUAdd.Add((sku != string.Empty) ? sku : upc, _indexadd++); clearData(); txtSKU.Focus(); } GrDSSKU.DataSource = _dsSKU; //_dsSKUAdd.Add((sku != string.Empty) ? sku : upc, _indexadd++); //clearData(); }
public void LoadPromotion(string sku) { try { TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, @"INVEVT.tps")); DataTable dt = access.GetDataTable_gia( (@"Select SKU,MeThod,Start,Stop,Qty1,DiscPrice,Code,Prc_Key ,Price,Pricetype from INVEVT where 1=1 and Method in (2,25,20,21,22) and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + @" <= stop and SKU='" + sku + "'")); //DataTable dt = access.GetDataTable_gia(("Select SKU,MeThod,START,Stop,Qty1,DiscPrice from INVEVT where 1=1 and Method in (2,25) " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + txtsku.Text + "'")), dETuNgay.DateTime, dEDenNgay.DateTime); if (dt.Rows.Count > 0) { flowLayoutPanel1.Controls.Clear(); tbM2.Rows.Clear(); tbM25.Rows.Clear(); tbM20.Rows.Clear(); tbM21.Rows.Clear(); tbM22.Rows.Clear(); dt = Fixtable(dt); //gridControl1.DataSource = dt; //gridView1.ExpandAllGroups(); //innitgrid(); if (tbM2.Select("MeThod=2").Length >= 1) { DataRow row; if (tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM2.Select("MeThod=2 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; string LabMethog2 = "Khi mua với SL " + Convert.ToInt32(row["Qty1"]).ToString("N0") + " giá tiền là " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " (" + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " -> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy") + ")"; LabelControl lmt2 = new LabelControl(); lmt2.Font = labKM.Font; lmt2.ForeColor = Color.Red; lmt2.Text = LabMethog2; flowLayoutPanel1.Controls.Add(lmt2); //+ " Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); } if (tbM25.Select("MeThod=25").Length >= 1) { DataRow row; if (tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM25.Select("MeThod=25 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel1.Visible = true; string labMethod25 = "Giá khuyến mãi tại POS : " + Convert.ToDecimal(row["Price"]).ToString("N2") + " (" + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " -> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy") + ")"; LabelControl lmt2 = new LabelControl(); lmt2.Font = labKM.Font; lmt2.ForeColor = Color.Red; lmt2.Text = labMethod25; flowLayoutPanel1.Controls.Add(lmt2); // +" Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslpos.Text = "1"; } #region khuyen mai theo so gia //if (_ListLabel.Count > 0) //{ // foreach (LabelControl labelControl in _ListLabel) // { // labelControl.Dispose(); // } //} //_ListLabel.Clear(); bool daApDungSoGia = false; if (tbM20.Select("MeThod=20").Length >= 1) { List <DataTable> list = GetTaleByPricetype(tbM20); int count = 0; foreach (DataTable dataTable in list) { DataRow row; if (dataTable.Select("MeThod=20 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dataTable.Select("MeThod=20 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dataTable.Select("MeThod=20 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dataTable.Select("MeThod=20 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } ////panel2.Visible = true; //LableValueGiam.Text = "Sổ giá giảm theo %(MeThod 20): " + row["Pricetype"].ToString() + // "_Giảm giá: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + // " % So với giá bán "; ////labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); //daApDungSoGia = true; LabelControl lable = new LabelControl(); //lable.ForeColor = LableSoGiaGiamTemp.ForeColor; lable.Font = labKM.Font; //LabelControl lablePtype = new LabelControl(); //lablePtype.ForeColor = labelControlPtype.ForeColor; //lablePtype.Font = labelControlPtype.Font; string strMT20 = "Sổ giá " + row["Pricetype"].ToString() + " "; // +" Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " So với giá bán "; //lablePtype.Location = new Point(262, 278 + count); //this.Controls.Add(lablePtype); //LabelControl lableValue = new LabelControl(); //lable.Text = "Sổ giá giảm theo %(Method 20):"; //lable.Location = new Point(34, 278 + count); //this.Controls.Add(lable); strMT20 += " Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " % so với giá bán " + " (" + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " -> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy") + ")"; lable.Text = strMT20; lable.ForeColor = Color.Red; flowLayoutPanel1.Controls.Add(lable); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } } if (tbM21.Select("MeThod=21").Length >= 1) { List <DataTable> list = GetTaleByPricetype(tbM21); int count = 0; foreach (DataTable dataTable in list) { DataRow row; if (dataTable.Select("MeThod=21 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dataTable.Select("MeThod=21 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dataTable.Select("MeThod=21 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dataTable.Select("MeThod=21 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } ////panel2.Visible = true; //LableValueGiam.Text = "Sổ giá giảm theo %(Method 21): " + row["Pricetype"].ToString() + // "_Giá khuyến mãi tại POS: " + // Convert.ToDecimal(row["DiscPrice"]).ToString("N0") + " "; ////labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); //daApDungSoGia = true; LabelControl lable = new LabelControl(); lable.Font = labKM.Font; lable.ForeColor = Color.Red; string strMT21 = "Sổ giá " + row["Pricetype"].ToString() + " "; strMT21 += " Giá khuyến mãi tại POS: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " (" + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " -> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy") + ")"; lable.Text = strMT21; flowLayoutPanel1.Controls.Add(lable); } } if (tbM22.Select("MeThod=22").Length >= 1) { List <DataTable> list = GetTaleByPricetype(tbM22); int count = 0; foreach (DataTable dataTable in list) { DataRow row; if (dataTable.Select("MeThod=22 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dataTable.Select("MeThod=22 and Prc_Key=Min(Prc_Key)")[0]; } else { //if(row["Pricetype"]) //{ //} Int32 prc_key = Convert.ToInt32(dataTable.Select("MeThod=22 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dataTable.Select("MeThod=22 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; LabelControl lable = new LabelControl(); string strMT22 = "Sổ giá " + row["Pricetype"].ToString() + " "; // +" Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " So với giá bán "; strMT22 += " Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " so với giá bán " + " (" + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " -> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy") + ")"; lable.Font = labKM.Font; lable.Text = strMT22; lable.ForeColor = Color.Red; flowLayoutPanel1.Controls.Add(lable); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } } #endregion } } catch (Exception ex) { CTLError.WriteError("FrmThongTinKMOfSKU LoadPromotion ", ex.Message); return; } }
public DataTable Fixtable(DataTable dt) { DataTable dataTable = new DataTable(); dataTable.Columns.AddRange(new DataColumn[] { new DataColumn("STT", typeof(System.Int32)) , new DataColumn("SKU", typeof(System.String)) , new DataColumn("Vendor", typeof(System.String)) , new DataColumn("MeThod", typeof(System.String)) , new DataColumn("Start", typeof(System.DateTime)) , new DataColumn("Stop", typeof(System.DateTime)) , new DataColumn("Qty1", typeof(System.Int32)) , new DataColumn("DiscPrice", typeof(System.Decimal)) , new DataColumn("DiscPriceKMTL", typeof(System.Decimal)) , new DataColumn("Code", typeof(System.Decimal)) , new DataColumn("Prc_Key", typeof(System.Int32)) , new DataColumn("Price", typeof(System.Decimal)) }); if (tbM2.Columns.Count == 0) { tbM2.Columns.AddRange(new DataColumn[] { new DataColumn("STT", typeof(System.Int32)) , new DataColumn("SKU", typeof(System.String)) , new DataColumn("MeThod", typeof(System.String)) , new DataColumn("Start", typeof(System.DateTime)) , new DataColumn("Stop", typeof(System.DateTime)) , new DataColumn("Qty1", typeof(System.Int32)) , new DataColumn("DiscPrice", typeof(System.Decimal)) , new DataColumn("Code", typeof(System.Decimal)) , new DataColumn("Prc_Key", typeof(System.Int32)) , new DataColumn("Price", typeof(System.Decimal)) }); } if (tbM25.Columns.Count == 0) { tbM25.Columns.AddRange(new DataColumn[] { new DataColumn("STT", typeof(System.Int32)) , new DataColumn("SKU", typeof(System.String)) , new DataColumn("MeThod", typeof(System.String)) , new DataColumn("Start", typeof(System.DateTime)) , new DataColumn("Stop", typeof(System.DateTime)) , new DataColumn("Qty1", typeof(System.Int32)) , new DataColumn("DiscPrice", typeof(System.Decimal)) , new DataColumn("Code", typeof(System.Decimal)) , new DataColumn("Prc_Key", typeof(System.Int32)) , new DataColumn("Price", typeof(System.Decimal)) }); } if (tbM20.Columns.Count == 0) { tbM20.Columns.AddRange(new DataColumn[] { new DataColumn("STT", typeof(System.Int32)) , new DataColumn("SKU", typeof(System.String)) , new DataColumn("MeThod", typeof(System.String)) , new DataColumn("Start", typeof(System.DateTime)) , new DataColumn("Stop", typeof(System.DateTime)) , new DataColumn("Qty1", typeof(System.Int32)) , new DataColumn("Pricetype", typeof(System.String)) , new DataColumn("DiscPrice", typeof(System.Decimal)) , new DataColumn("Code", typeof(System.Decimal)) , new DataColumn("Prc_Key", typeof(System.Int32)) , new DataColumn("Price", typeof(System.Decimal)) }); } if (tbM21.Columns.Count == 0) { tbM21.Columns.AddRange(new DataColumn[] { new DataColumn("STT", typeof(System.Int32)) , new DataColumn("SKU", typeof(System.String)) , new DataColumn("MeThod", typeof(System.String)) , new DataColumn("Start", typeof(System.DateTime)) , new DataColumn("Stop", typeof(System.DateTime)) , new DataColumn("Qty1", typeof(System.Int32)) , new DataColumn("Pricetype", typeof(System.String)) , new DataColumn("DiscPrice", typeof(System.Decimal)) , new DataColumn("Code", typeof(System.Decimal)) , new DataColumn("Prc_Key", typeof(System.Int32)) , new DataColumn("Price", typeof(System.Decimal)) }); } if (tbM22.Columns.Count == 0) { tbM22.Columns.AddRange(new DataColumn[] { new DataColumn("STT", typeof(System.Int32)) , new DataColumn("SKU", typeof(System.String)) , new DataColumn("MeThod", typeof(System.String)) , new DataColumn("Start", typeof(System.DateTime)) , new DataColumn("Stop", typeof(System.DateTime)) , new DataColumn("Qty1", typeof(System.Int32)) , new DataColumn("Pricetype", typeof(System.String)) , new DataColumn("DiscPrice", typeof(System.Decimal)) , new DataColumn("Code", typeof(System.Decimal)) , new DataColumn("Prc_Key", typeof(System.Int32)) , new DataColumn("Price", typeof(System.Decimal)) }); } int i = 0; foreach (DataRow dataRow in dt.Rows) { i++; DataRow row = dataTable.NewRow(); row["STT"] = i; row["SKU"] = dataRow["SKU"]; if (dataRow["MeThod"].ToString().Trim() == "25") { row["MeThod"] = "Giảm giá tại POS"; } else if (dataRow["MeThod"].ToString().Trim() == "2") { row["MeThod"] = "Giảm giá theo lượng"; } else { row["MeThod"] = "khuyến mãi theo sổ giá"; } if (dataRow["Code"].ToString() != string.Empty) { row["Code"] = Convert.ToDecimal(dataRow["Code"]).ToString("N0"); } else { row["Code"] = 0; } string sokhong = "00000"; TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, "INVHPR.TPS")); DataTable tbtemp = access.GetDataTable_gia(string.Format(@"Select Description from INVHPR where Code='{0}'", sokhong.Substring(0, 6 - row["Code"].ToString().Trim().Length) + row["Code"])); if (tbtemp.Rows.Count > 0) { row["Vendor"] = tbtemp.Rows[0][0]; } row["Start"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Start"]) - _Const_datetime); row["Stop"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Stop"]) - _Const_datetime); row["Qty1"] = Convert.ToInt32(dataRow["Qty1"]).ToString("N0"); row["DiscPrice"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); if (dataRow["MeThod"].ToString().Trim() == "2") { row["DiscPriceKMTL"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); } else { row["DiscPriceKMTL"] = 0; } if (dataRow["Prc_Key"].ToString() != string.Empty) { row["Prc_Key"] = Convert.ToInt64(dataRow["Prc_Key"]).ToString("N0"); } else { row["Prc_Key"] = 0; } row["Price"] = Convert.ToDecimal(dataRow["Price"]).ToString("N2"); dataTable.Rows.Add(row); if (dataRow["MeThod"].ToString().Trim() == "2") { DataRow row2 = tbM2.NewRow(); row2["STT"] = i; row2["SKU"] = dataRow["SKU"]; row2["MeThod"] = dataRow["MeThod"]; row2["Start"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Start"]) - _Const_datetime); row2["Stop"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Stop"]) - _Const_datetime); row2["Qty1"] = Convert.ToInt32(dataRow["Qty1"]).ToString("N0"); row2["DiscPrice"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); if (dataRow["Code"].ToString() != string.Empty) { row2["Code"] = Convert.ToDecimal(dataRow["Code"]).ToString("N0"); } else { row2["Code"] = 0; } if (dataRow["Prc_Key"].ToString() != string.Empty) { row2["Prc_Key"] = Convert.ToInt32(dataRow["Prc_Key"]).ToString("N0"); } else { row2["Prc_Key"] = 0; } row2["Price"] = Convert.ToDecimal(dataRow["Price"]).ToString("N2"); tbM2.Rows.Add(row2); } else if (dataRow["MeThod"].ToString().Trim() == "25") { DataRow row25 = tbM25.NewRow(); row25["STT"] = i; row25["SKU"] = dataRow["SKU"]; row25["MeThod"] = dataRow["MeThod"]; row25["Start"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Start"]) - _Const_datetime); row25["Stop"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Stop"]) - _Const_datetime); row25["Qty1"] = Convert.ToInt32(dataRow["Qty1"]).ToString("N0"); row25["DiscPrice"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); if (dataRow["Code"].ToString() != string.Empty) { row25["Code"] = Convert.ToDecimal(dataRow["Code"]).ToString("N0"); } else { row25["Code"] = 0; } if (dataRow["Prc_Key"].ToString() != string.Empty) { row25["Prc_Key"] = Convert.ToInt32(dataRow["Prc_Key"]).ToString("N0"); } else { row25["Prc_Key"] = 0; } row25["Price"] = Convert.ToDecimal(dataRow["Price"]).ToString("N2"); tbM25.Rows.Add(row25); } else if (dataRow["MeThod"].ToString().Trim() == "20") { DataRow row20 = tbM20.NewRow(); row20["STT"] = i; row20["SKU"] = dataRow["SKU"]; row20["MeThod"] = dataRow["MeThod"]; row20["Pricetype"] = dataRow["Pricetype"]; row20["Start"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Start"]) - _Const_datetime); row20["Stop"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Stop"]) - _Const_datetime); row20["Qty1"] = Convert.ToInt32(dataRow["Qty1"]).ToString("N0"); row20["DiscPrice"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); if (dataRow["Code"].ToString() != string.Empty) { row20["Code"] = Convert.ToDecimal(dataRow["Code"]).ToString("N0"); } else { row20["Code"] = 0; } if (dataRow["Prc_Key"].ToString() != string.Empty) { row20["Prc_Key"] = Convert.ToInt32(dataRow["Prc_Key"]).ToString("N0"); } else { row20["Prc_Key"] = 0; } row20["Price"] = Convert.ToDecimal(dataRow["Price"]).ToString("N2"); tbM20.Rows.Add(row20); } else if (dataRow["MeThod"].ToString().Trim() == "21") { DataRow row21 = tbM21.NewRow(); row21["STT"] = i; row21["SKU"] = dataRow["SKU"]; row21["MeThod"] = dataRow["MeThod"]; row21["Pricetype"] = dataRow["Pricetype"]; row21["Start"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Start"]) - _Const_datetime); row21["Stop"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Stop"]) - _Const_datetime); row21["Qty1"] = Convert.ToInt32(dataRow["Qty1"]).ToString("N0"); row21["DiscPrice"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); if (dataRow["Code"].ToString() != string.Empty) { row21["Code"] = Convert.ToDecimal(dataRow["Code"]).ToString("N0"); } else { row21["Code"] = 0; } if (dataRow["Prc_Key"].ToString() != string.Empty) { row21["Prc_Key"] = Convert.ToInt32(dataRow["Prc_Key"]).ToString("N0"); } else { row21["Prc_Key"] = 0; } row21["Price"] = Convert.ToDecimal(dataRow["Price"]).ToString("N2"); tbM21.Rows.Add(row21); } else if (dataRow["MeThod"].ToString().Trim() == "22") { DataRow row22 = tbM22.NewRow(); row22["STT"] = i; row22["SKU"] = dataRow["SKU"]; row22["MeThod"] = dataRow["MeThod"]; row22["Pricetype"] = dataRow["Pricetype"]; row22["Start"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Start"]) - _Const_datetime); row22["Stop"] = DateTime.FromOADate(Convert.ToDouble(dataRow["Stop"]) - _Const_datetime); row22["Qty1"] = Convert.ToInt32(dataRow["Qty1"]).ToString("N0"); row22["DiscPrice"] = Convert.ToDecimal(dataRow["DiscPrice"]).ToString("N2"); if (dataRow["Code"].ToString() != string.Empty) { row22["Code"] = Convert.ToDecimal(dataRow["Code"]).ToString("N0"); } else { row22["Code"] = 0; } if (dataRow["Prc_Key"].ToString() != string.Empty) { row22["Prc_Key"] = Convert.ToInt32(dataRow["Prc_Key"]).ToString("N0"); } else { row22["Prc_Key"] = 0; } row22["Price"] = Convert.ToDecimal(dataRow["Price"]).ToString("N2"); tbM22.Rows.Add(row22); } } return(dataTable); }
private void FrmCheckGia_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5 || e.KeyCode == Keys.Enter) { if (txtsku.Text != string.Empty) { string masku = txtsku.Text; if (txtsku.Text.Length <= 7) { masku = "00" + txtsku.Text; } else if (txtsku.Text.Length > 7) { if (txtsku.Text.Length <= 14) { masku = GetSKU(PhatSinhUPC.Substring(0, 18 - txtsku.Text.Length) + txtsku.Text); } else { masku = GetSKU(txtsku.Text); } } TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, this._pathFileDM)); DataTable dt = access.GetDataTable("Select SKU,Description,Price,Vendor,Buy_Unit,Sell_Unit from INVMST where 1=1" + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + masku + "'")); if (dt.Rows.Count > 0) { labgiapos.Text = "Không có khuyến mãi tại POS"; //labslKMTL.Text = "0"; labGiaKMTL.Text = "Không có khuyến mãi theo lượng"; _sku = dt.Rows[0]["SKU"].ToString(); labten.Text = dt.Rows[0]["Description"].ToString(); labgia.Text = Convert.ToDecimal(dt.Rows[0]["PRICE"]).ToString("N2"); labelVendor.Text = dt.Rows[0]["Vendor"].ToString(); labelBuyUnit.Text = dt.Rows[0]["Buy_Unit"].ToString(); labelSelunit.Text = dt.Rows[0]["Sell_Unit"].ToString(); LoadPromo(_sku); txtsku.Clear(); return; } else { _sku = ""; labten.Text = "_ _"; labgia.Text = "_ _"; labelSelunit.Text = "_ _"; labelBuyUnit.Text = "_ _"; labelVendor.Text = "_ _"; //labslpos.Text = "0"; labgiapos.Text = "Không có khuyến mãi tại POS"; //labslKMTL.Text = "0"; labGiaKMTL.Text = "Không có khuyến mãi theo lượng"; //panel2.Visible = false; //panel1.Visible = false; gridControl1.DataSource = null; if (_ListLabel.Count > 0) { foreach (LabelControl labelControl in _ListLabel) { labelControl.Dispose(); } } _ListLabel.Clear(); } //if (txtsku.Text.Length == 7 || txtsku.Text.Length == 13) //{ // string ma13 = ""; // SQLHelper helper = new SQLHelper(); // DataTable dtcustommer = helper.InfoCustommer(txtsku.Text); // if (dtcustommer != null) // if (dtcustommer.Rows.Count > 0) // { // ConvertBarCode cv = new ConvertBarCode(); // if (Convert.ToInt64(txtsku.Text) > 25000) // ma13 = cv.CreaBarCode(txtsku.Text); // else if (txtsku.Text.Length != 13) // ma13 = cv.CreaBarCodeTV(txtsku.Text); // if (txtsku.Text.Length == 13) // ma13 = txtsku.Text; // Frmkiot frmkiot = new Frmkiot(this, dtcustommer, ma13); // frmkiot.rtbarcode += new Frmkiot.ReturnBarcode(retunbarcode); // this.OpenDialog(frmkiot); // //txtsku.Clear(); // } //} if (txtsku.Text.Length > 13) { txtsku.Clear(); } } else { labten.Text = "_ _"; labgia.Text = "_ _"; labelSelunit.Text = "_ _"; labelBuyUnit.Text = "_ _"; labelVendor.Text = "_ _"; labgiapos.Text = "Không có khuyến mãi tại POS"; //labslKMTL.Text = "0"; labGiaKMTL.Text = "Không có khuyến mãi theo lượng"; gridControl1.DataSource = null; if (_ListLabel.Count > 0) { foreach (LabelControl labelControl in _ListLabel) { labelControl.Dispose(); } } _ListLabel.Clear(); //panel2.Visible = false; //panel1.Visible = false; txtsku.Clear(); return; } txtsku.Clear(); } }
public void ImPort_Excel() { DataTable dt = new DataTable(); try { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "*.xls|*.xls|*.xlsx|*.xlsx"; CTLImportExcel excel = new CTLImportExcel(); if (dialog.ShowDialog() == DialogResult.OK) { FileInfo file = new FileInfo(dialog.FileName); if (file.Extension.ToString().Trim().ToUpper() == ".XLS") { dt = excel.getDataFromXLS(dialog.FileName); } else if (file.Extension.ToString().Trim().ToUpper() == ".XLSX") { dt = excel.getDataFromXLS2007(dialog.FileName); } int dem = 0; foreach (DataColumn col in dt.Columns) { if (col.ColumnName.ToUpper() == "SKU") { dem++; } } if (dem == 0) { return; } string listma = LayDKMaSKUsql(dt); if (listma.Trim() == "and SKU in )") { return; } if (dt.Rows.Count >= 1) {//code cu TPSDataAccess access = new TPSDataAccess(_PathFileINVMST); // DataTable source = access.GetTableDM(@"Select SKU,UPC,Description,Price,CurrencyCode,Sell_Unit from INVMST // where 1=1 "+listma); // if (source.Rows.Count >= 1) // GridDSMa.DataSource = source; //sua lai DataTable dttemp = new DataTable(); dttemp.Columns.Add("SKU"); dttemp.Columns.Add("UPC"); dttemp.Columns.Add("Description"); dttemp.Columns.Add("Price"); dttemp.Columns.Add("CurrencyCode"); dttemp.Columns.Add("Sell_Unit"); foreach (DataRow r in dt.Rows) { if (r["SKU"].ToString() != string.Empty) { DataTable source = access.GetTableDM(string.Format(@"Select SKU,UPC,Description,Price,CurrencyCode,Sell_Unit from INVMST where 1=1 and sku='{0}'", r["SKU"].ToString())); if (source.Rows.Count > 0) { DataRow nrow = dttemp.NewRow(); nrow["SKU"] = source.Rows[0]["SKU"]; nrow["UPC"] = source.Rows[0]["UPC"]; nrow["Description"] = source.Rows[0]["Description"]; nrow["Price"] = source.Rows[0]["Price"]; nrow["CurrencyCode"] = source.Rows[0]["CurrencyCode"]; nrow["Sell_Unit"] = source.Rows[0]["Sell_Unit"]; dttemp.Rows.Add(nrow); } } } if (dttemp.Rows.Count > 0) { GridDSMa.DataSource = dttemp; } } } } catch (Exception ex) { CTLError.WriteError("FrmImportfile ImportExcel", ex.Message); return; throw new Exception(ex.Message); } }
public void LoadPromo(string sku) { if (_sku == string.Empty) { return; } string masku = txtsku.Text; if (txtsku.Text.Length <= 7) { masku = "00" + txtsku.Text; } else if (txtsku.Text.Length > 9) { if (txtsku.Text.Length <= 14) { masku = GetSKU(PhatSinhUPC.Substring(0, 18 - txtsku.Text.Length) + txtsku.Text); } else { masku = GetSKU(txtsku.Text); } } TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, this._pathFileGia)); DataTable dt = access.GetDataTable_gia((@"Select SKU,MeThod,Start,Stop,Qty1,DiscPrice,Code,Prc_Key ,Price,Pricetype from INVEVT where 1=1 and Method in (2,25,20,21,22) and " + ((Int64)DateTime.Now.ToOADate() + _Const_datetime) + @" >= Start and " + ((Int64)DateTime.Now.ToOADate() + _Const_datetime) + " <= stop " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + masku + "'")) ); //DataTable dt = access.GetDataTable_gia(("Select SKU,MeThod,START,Stop,Qty1,DiscPrice from INVEVT where 1=1 and Method in (2,25) " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + txtsku.Text + "'")), dETuNgay.DateTime, dEDenNgay.DateTime); if (dt.Rows.Count > 0) { tbM2.Rows.Clear(); tbM25.Rows.Clear(); tbM20.Rows.Clear(); tbM21.Rows.Clear(); tbM22.Rows.Clear(); dt = Fixtable(dt); gridControl1.DataSource = dt; gridView1.ExpandAllGroups(); innitgrid(); if (tbM2.Select("MeThod=2").Length >= 1) { DataRow row; if (tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM2.Select("MeThod=2 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; labGiaKMTL.Text = "Khi mua với SL " + Convert.ToInt32(row["Qty1"]).ToString("N0") + " giá tiền là " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2"); //+ " Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); } else { labGiaKMTL.Text = "Không có giảm giá theo lượng"; //panel2.Visible = false; //labslKMTL.Text = "0"; } if (tbM25.Select("MeThod=25").Length >= 1) { DataRow row; if (tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM25.Select("MeThod=25 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel1.Visible = true; labgiapos.Text = " " + Convert.ToDecimal(row["Price"]).ToString("N2");// +" Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslpos.Text = "1"; } else { labgiapos.Text = "Không có khuyến mãi tại POS"; //panel1.Visible = false; //labslpos.Text = "0"; } #region khuyen mai theo so gia if (_ListLabel.Count > 0) { foreach (LabelControl labelControl in _ListLabel) { labelControl.Dispose(); } } _ListLabel.Clear(); int count = 0; bool daApDungSoGia = false; if (tbM20.Select("MeThod=20").Length >= 1) { List <DataTable> list = GetTaleByPricetype(tbM20); foreach (DataTable dataTable in list) { DataRow row; if (dataTable.Select("MeThod=20 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dataTable.Select("MeThod=20 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dataTable.Select("MeThod=20 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dataTable.Select("MeThod=20 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } ////panel2.Visible = true; //LableValueGiam.Text = "Sổ giá giảm theo %(MeThod 20): " + row["Pricetype"].ToString() + // "_Giảm giá: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + // " % So với giá bán "; ////labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); //daApDungSoGia = true; LabelControl lable = new LabelControl(); lable.ForeColor = LableSoGiaGiamTemp.ForeColor; lable.Font = LableSoGiaGiamTemp.Font; LabelControl lablePtype = new LabelControl(); lablePtype.ForeColor = labelControlPtype.ForeColor; lablePtype.Font = labelControlPtype.Font; lablePtype.Text = row["Pricetype"].ToString();// +" Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " So với giá bán "; lablePtype.Location = new Point(262, 278 + count); this.Controls.Add(lablePtype); LabelControl lableValue = new LabelControl(); lable.Text = "Sổ giá giảm theo %(Method 20):"; lable.Location = new Point(34, 278 + count); this.Controls.Add(lable); lableValue.ForeColor = LableValueGiam.ForeColor; lableValue.Font = LableValueGiam.Font; lableValue.Text = " Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " % so với giá bán "; lableValue.Location = new Point(311, 278 + count); this.Controls.Add(lableValue); count += 21; _ListLabel.Add(lable); _ListLabel.Add(lableValue); _ListLabel.Add(lablePtype); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } } else if (!daApDungSoGia) { //LableValueGiam.Text = "Không giảm giá theo sổ giá"; //panel2.Visible = false; //labslKMTL.Text = "0"; } if (tbM21.Select("MeThod=21").Length >= 1) { List <DataTable> list = GetTaleByPricetype(tbM21); foreach (DataTable dataTable in list) { DataRow row; if (dataTable.Select("MeThod=21 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dataTable.Select("MeThod=21 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(dataTable.Select("MeThod=21 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dataTable.Select("MeThod=21 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } ////panel2.Visible = true; //LableValueGiam.Text = "Sổ giá giảm theo %(Method 21): " + row["Pricetype"].ToString() + // "_Giá khuyến mãi tại POS: " + // Convert.ToDecimal(row["DiscPrice"]).ToString("N0") + " "; ////labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); //daApDungSoGia = true; LabelControl lable = new LabelControl(); lable.ForeColor = LableSoGiaGiamTemp.ForeColor; lable.Font = LableSoGiaGiamTemp.Font; LabelControl lablePtype = new LabelControl(); lablePtype.ForeColor = labelControlPtype.ForeColor; lablePtype.Font = labelControlPtype.Font; lablePtype.Text = row["Pricetype"].ToString();// +" Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " So với giá bán "; lablePtype.Location = new Point(262, 278 + count); this.Controls.Add(lablePtype); LabelControl lableValue = new LabelControl(); lable.Text = "Sổ giá giảm theo %(Method 21):"; lable.Location = new Point(34, 278 + count); this.Controls.Add(lable); lableValue.ForeColor = LableValueGiam.ForeColor; lableValue.Font = LableValueGiam.Font; lableValue.Text = " Giá khuyến mãi tại POS: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2"); lableValue.Anchor = LableValueGiam.Anchor; lableValue.Location = new Point(311, 278 + count); this.Controls.Add(lableValue); count += 21; _ListLabel.Add(lable); _ListLabel.Add(lableValue); _ListLabel.Add(lablePtype); lable.Visible = true; lableValue.Visible = true; } } else if (!daApDungSoGia) { //LableValueGiam.Text = "Không giảm giá theo sổ giá"; //panel2.Visible = false; //labslKMTL.Text = "0"; } if (tbM22.Select("MeThod=22").Length >= 1) { List <DataTable> list = GetTaleByPricetype(tbM22); foreach (DataTable dataTable in list) { DataRow row; if (dataTable.Select("MeThod=22 and Prc_Key=Min(Prc_Key)").Length == 1) { row = dataTable.Select("MeThod=22 and Prc_Key=Min(Prc_Key)")[0]; } else { //if(row["Pricetype"]) //{ //} Int32 prc_key = Convert.ToInt32(dataTable.Select("MeThod=22 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = dataTable.Select("MeThod=22 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; LabelControl lable = new LabelControl(); lable.ForeColor = LableSoGiaGiamTemp.ForeColor; lable.Font = LableSoGiaGiamTemp.Font; LabelControl lablePtype = new LabelControl(); lablePtype.ForeColor = labelControlPtype.ForeColor; lablePtype.Font = labelControlPtype.Font; lablePtype.Text = row["Pricetype"].ToString();// +" Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " So với giá bán "; lablePtype.Location = new Point(262, 278 + count); this.Controls.Add(lablePtype); LabelControl lableValue = new LabelControl(); lable.Text = "Sổ giá giảm theo %(Method 22):"; lable.Location = new Point(34, 278 + count); this.Controls.Add(lable); lableValue.ForeColor = LableValueGiam.ForeColor; lableValue.Font = LableValueGiam.Font; lableValue.Text = " Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " so với giá bán "; lableValue.Location = new Point(311, 278 + count); this.Controls.Add(lableValue); count += 21; _ListLabel.Add(lable); _ListLabel.Add(lableValue); _ListLabel.Add(lablePtype); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } } else if (!daApDungSoGia) { //LableValueGiam.Text = "Không giảm giá theo sổ giá"; ////panel2.Visible = false; ////labslKMTL.Text = "0"; //if(_ListLabel.Count>0) //{ // foreach (LabelControl labelControl in _ListLabel) // { // labelControl.Dispose(); // } //} //_ListLabel.Clear(); } #endregion } else { gridControl1.DataSource = null; if (_ListLabel.Count > 0) { foreach (LabelControl labelControl in _ListLabel) { labelControl.Dispose(); } } _ListLabel.Clear(); //panel2.Visible = false; //panel1.Visible = false; //innitgrid(); } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //if (textBox1.Text.Length==13) //{ // textBox1.Text = textBox1.Text.Substring(2, 10); //} if (textBox1.Text.Length != 10) { labthongbao.Visible = true; labthongbao.Text = "Vui long nhap Ma 10 cua KH"; return; } //if (textBox1.Text.Length == 10 &&radKHTT.Checked) //{ // string ma13 = ""; // SQLHelper helper = new SQLHelper(); // DataTable dtcustommer = helper.InfoCustommer(textBox1.Text.Substring(3,7)); // if (dtcustommer != null) // { // if (dtcustommer.Rows.Count > 0) // { // //_sogiay = 60; // //if (Config._timemer != null) // // _sogiay = Convert.ToInt32(Config._timemer) * 60; // ConvertBarCode cv = new ConvertBarCode(); // //if (Convert.ToInt64(textBox1.Text) > 25000) // ma13 = cv.CreaBarCode(textBox1.Text.Substring(3, 7)); // //else if (textBox1.Text.Length != 13) // // ma13 = cv.CreaBarCodeTV(textBox1.Text); // //if (textBox1.Text.Length == 13) // // ma13 = textBox1.Text; // //Frmkiot frmkiot = new Frmkiot(this, dtcustommer, ma13); // //this.OpenDialog(frmkiot); // if (dtcustommer.Rows.Count <= 0) // return; // labhoten.Text = dtcustommer.Rows[0]["HoLot"].ToString() + " " + dtcustommer.Rows[0]["Ten"].ToString(); // labsodt.Text = (dtcustommer.Rows[0]["DTDD"].ToString() == string.Empty) ? dtcustommer.Rows[0]["DTBan"].ToString() : dtcustommer.Rows[0]["DTDD"].ToString(); // labmathe.Text = dtcustommer.Rows[0]["MaThe13"].ToString(); // DataTable dt = helper.GetInfoCustommer(ma13); // if (dt == null) // { // labdiemmuahangChinhthuc.Text = "_ _"; // labdiemthuongChinhthuc.Text = "_ _"; // labdiemdasudungChinhThuc.Text = "_ _"; // labdiemconlaiChinhthuc.Text = "_ _"; // labdiemmuahangGhinhan.Text = "_ _"; // labDiemThuongGhiNhan.Text = "_ _"; // labDiemDaSuDungGhiNhan.Text = "_ _"; // labDiemConLaiGiNhan.Text = "_ _"; // labSoPhieuQuaTang.Text = "_ _"; // labNgayIn.Text = DateTime.Now.ToString("dd/MM/yyyy"); // labDiemConLaiNamTruoc.Text = "_ _"; // labdiemmuahangchinhthucdenhet.Text = "_ _"; // } // else // { // loadThongTin(dt); // } // textBox1.Clear(); // } // else if (textBox1.Text.Length == 13) // { // if (rtbarcode != null) // { // rtbarcode(textBox1.Text); // this.Close(); // } // } // } // else if (textBox1.Text.Length == 13) // { // if (rtbarcode != null) // { // rtbarcode(textBox1.Text); // this.Close(); // } // } //} labthongbao.Visible = false; if (textBox1.Text.Length == 10 && radWDSS.Checked) { //code get infomation cust Windss TPSDataAccess access = new TPSDataAccess("H:\\Data\\CUST.tps"); DataTable source = access.GetTableDM(@"Select Mcreatedate,Xlastmoddate,Pricecategory,Pclienttype,Allowchrg,Mfname,Mlname,Mcustnum,Jcuststatus from CUST where Mcustnum=" + textBox1.Text); if (source != null && source.Rows.Count > 0) { labWMa.Text = source.Rows[0]["Mcustnum"].ToString(); //labWten.Text = source.Rows[0]["Mlname"].ToString() + " " + source.Rows[0]["Mfname"].ToString(); labWngaytao.Text = source.Rows[0]["Mcreatedate"] != null ? ((DateTime)source.Rows[0]["Mcreatedate"]).ToString("dd/MM/yyyy") : ""; labWngaychinhsua.Text = source.Rows[0]["Jcuststatus"].ToString(); labWSogia.Text = source.Rows[0]["Pricecategory"].ToString(); labWLoaiKH.Text = source.Rows[0]["Pclienttype"].ToString(); labWmuano.Text = source.Rows[0]["Allowchrg"].ToString(); } else { labthongbao.Visible = true; labthongbao.Text = "Vui lòng kiểm tra mã KH khác"; labWMa.Text = "_ _"; //labWten.Text = "_ _"; labWngaytao.Text = "_ _"; labWngaychinhsua.Text = "_ _"; labWSogia.Text = "_ _"; labWLoaiKH.Text = "_ _"; labWmuano.Text = "_ _"; } } if (textBox1.Text.Length > 13) { textBox1.Clear(); } } }
private void txtsku_TextChanged_1(object sender, EventArgs e) { if (txtsku.Text == string.Empty) { //labten.Text = "_ _"; //labgia.Text = "_ _"; //labslpos.Text = "0"; //labgiapos.Text = "_ _"; //labslKMTL.Text = "0"; //labGiaKMTL.Text = "_ _"; //gridControl1.DataSource = null; return; } if (txtsku.Text != string.Empty) { string masku = txtsku.Text; if (txtsku.Text.Length <= 7) { masku = "00" + txtsku.Text; } else if (txtsku.Text.Length > 9) { if (txtsku.Text.Length <= 14) { masku = GetSKU(PhatSinhUPC.Substring(0, 18 - txtsku.Text.Length) + txtsku.Text); } else { masku = GetSKU(txtsku.Text); } } try { Image myimg = Code128Rendering.MakeBarcodeImage(masku, 3, true); pictureBox2.Image = myimg; } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text); } TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, this._pathFileDM)); DataTable dt = access.GetDataTable("Select SKU,Description,Price from INVMST where 1=1" + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + masku + "'")); if (dt.Rows.Count > 0) { _sogiay = 60; if (Config._timemer != string.Empty) { _sogiay = Convert.ToInt64(Config._timemer) * 60; } flag = true; labelControl3.Visible = true; labelControl5.Visible = true; labten.Visible = true; labgia.Visible = true; pictureBox2.Visible = true; pictBarcode.Visible = true; labGiaKMTL.Visible = true; labslKMTL.Visible = true; labelControl10.Visible = true; labgiapos.Visible = true; labslpos.Visible = true; labelControl4.Visible = true; labnameItem.Visible = true; labelMa13.Visible = true; labGiaMH.Visible = true; _sku = dt.Rows[0]["SKU"].ToString(); labten.Text = dt.Rows[0]["Description"].ToString(); labgia.Text = Convert.ToDecimal(dt.Rows[0]["PRICE"]).ToString("N2") + " VND"; labnameItem.Text = dt.Rows[0]["Description"].ToString(); //labGiaMH.Text ="Giá Gốc: "+ Convert.ToDecimal(dt.Rows[0]["PRICE"]).ToString("N2"); labelMa13.Text = _sku; LoadPromo(_sku); //txtsku.Clear(); } else { labten.Text = "_ _"; labgia.Text = "_ _"; labslpos.Text = "0"; labgiapos.Text = "_ _"; labslKMTL.Text = "0"; labGiaKMTL.Text = "_ _"; labelControl3.Visible = false; labelControl5.Visible = false; labten.Visible = false; labgia.Visible = false; pictureBox2.Visible = false; pictBarcode.Visible = false; labGiaKMTL.Visible = false; labslKMTL.Visible = false; labelControl10.Visible = false; labgiapos.Visible = false; labslpos.Visible = false; labelControl4.Visible = false; labnameItem.Visible = false; labelMa13.Visible = false; labGiaMH.Visible = false; //gridControl1.DataSource = null; //return; } if (txtsku.Text.Length == 7 || txtsku.Text.Length == 13) { string ma13 = ""; SQLHelper helper = new SQLHelper(); DataTable dtcustommer = helper.InfoCustommer(txtsku.Text); if (dtcustommer != null) { if (dtcustommer.Rows.Count > 0) { ConvertBarCode cv = new ConvertBarCode(); if (Convert.ToInt64(txtsku.Text) > 25000) { ma13 = cv.CreaBarCode(txtsku.Text); } else if (txtsku.Text.Length != 13) { ma13 = cv.CreaBarCodeTV(txtsku.Text); } if (txtsku.Text.Length == 13) { ma13 = txtsku.Text; } Frmkiot frmkiot = new Frmkiot(this, dtcustommer, ma13); frmkiot.rtbarcode += new Frmkiot.ReturnBarcode(retunbarcode); this.OpenDialog(frmkiot); txtsku.Clear(); } } } if (txtsku.Text.Length > 13) { txtsku.Clear(); } } }
public string GetSKU(string UPC) { TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, _pathFileUPC)); return(access.GetSkuToUPC(UPC)); }
public void LoadPromo(string sku) { if (_sku == string.Empty) { return; } string masku = txtsku.Text; if (txtsku.Text.Length <= 7) { masku = "00" + txtsku.Text; } else if (txtsku.Text.Length > 9) { if (txtsku.Text.Length <= 14) { masku = GetSKU(PhatSinhUPC.Substring(0, 18 - txtsku.Text.Length) + txtsku.Text); } else { masku = GetSKU(txtsku.Text); } } TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, this._pathFileGia)); DataTable dt = access.GetDataTable_gia((@"Select SKU,MeThod,Start,Stop,Qty1,DiscPrice,Code,Prc_Key ,Price from INVEVT where 1=1 and Method in (2,25) and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + " <= stop " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + masku + "'")) ); //DataTable dt = access.GetDataTable_gia(("Select SKU,MeThod,START,Stop,Qty1,DiscPrice from INVEVT where 1=1 and Method in (2,25) " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + txtsku.Text + "'")), dETuNgay.DateTime, dEDenNgay.DateTime); if (dt.Rows.Count > 0) { tbM2.Rows.Clear(); tbM25.Rows.Clear(); dt = Fixtable(dt); //gridControl1.DataSource = dt; //gridView1.ExpandAllGroups(); innitgrid(); if (tbM2.Select("MeThod=2").Length >= 1) { DataRow row; if (tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]; labGiaMH.Text = "Thời gian : " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " ==> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); } else { Int32 prc_key = Convert.ToInt32(tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM2.Select("MeThod=2 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; labGiaMH.Text = "Thời gian : " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " ==> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); } labGiaKMTL.Text = Convert.ToDecimal(row["DiscPrice"]).ToString("N2"); labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); labGiaKMTL.Visible = true; labslKMTL.Visible = true; labelControl10.Visible = true; } else { labGiaKMTL.Text = "0"; labslKMTL.Text = "0"; labGiaKMTL.Visible = false; labslKMTL.Visible = false; labelControl10.Visible = false; } if (tbM25.Select("MeThod=25").Length >= 1) { DataRow row; if (tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]; labGiaMH.Text = "Thời gian : " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " ==> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); } else { Int32 prc_key = Convert.ToInt32(tbM2.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM25.Select("MeThod=25 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; labGiaMH.Text = "Thời gian : " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " ==> " + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); } labgiapos.Text = Convert.ToDecimal(row["Price"]).ToString("N2"); labslpos.Text = "1"; labgiapos.Visible = true; labslpos.Visible = true; labelControl4.Visible = true; } else { labgiapos.Text = "_ _"; labslpos.Text = "0"; labgiapos.Visible = false; labslpos.Visible = false; labelControl4.Visible = false; } } else { labGiaKMTL.Visible = false; labslKMTL.Visible = false; labelControl10.Visible = false; labgiapos.Visible = false; labslpos.Visible = false; labelControl4.Visible = false; labGiaMH.Visible = false; //gridControl1.DataSource = null; //innitgrid(); } }
private void simpleButton1_Click(object sender, EventArgs e) { string upc = ""; string sku = ""; if (gridView1.RowCount >= 30) { InfoMessage.HienThi("Số lượng SKU cho phép xuất bảng giá là 30 !", "Vui lòng kiểm tra lại", "Thong bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } if (txtSKU.Text == string.Empty || txtSKU.Text.Length > 18) { return; } string where = ""; if (txtSKU.Text.Length <= 9) { sku = _sokhong.Substring(0, 9 - txtSKU.Text.Length) + txtSKU.Text; where = " and SKU='" + sku + "'"; } else { upc = _sokhong.Substring(0, 18 - txtSKU.Text.Length) + txtSKU.Text; where = " and UPC='" + upc + "'"; } if (!validate((sku != string.Empty) ? sku : upc)) { InfoMessage.HienThi("SKU đã có trong danh sách!", "Vui lòng thay đổi số lượng trong lưới", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } TPSDataAccess dataAccess = new TPSDataAccess(_PathFileINVMST); TPSDataAccess dataAccessKM = new TPSDataAccess(_PathFileINVEVT); DataTable dt = new DataTable(); dt = dataAccess.GetTableDM("Select SKU,UPC,Description,Price From INVMST where 1=1 " + where); if (dt == null || dt.Rows.Count <= 0) { InfoMessage.HienThi("SKU không có trong danh mục!", "Vui lòng kiểm tra lại", "Thong Bao", HinhAnhThongBao.THONGTIN, NutThongBao.DONGY); return; } DataTable dtKM = new DataTable(); dtKM = dataAccessKM.GetTableDM("select SKU,QTY1,DISCPRICE,Method From INVEVT where SKU='" + dt.Rows[0]["SKU"].ToString() + "' and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + " <= stop "); DataRow r = _dsSKU.NewRow(); r["SKU"] = dt.Rows[0]["SKU"].ToString(); r["UPC"] = dt.Rows[0]["UPC"].ToString(); r["Description"] = dt.Rows[0]["Description"].ToString(); r["SoLuong"] = txtsoluong.Value; r["GiaGoc"] = dt.Rows[0]["Price"].ToString(); r["ThanhTien"] = r["GiaGoc"]; if (dtKM.Rows.Count > 0) { r["Method"] = dtKM.Rows[0]["Method"].ToString(); r["DISCPRICE"] = dtKM.Rows[0]["DISCPRICE"].ToString(); r["QTY1"] = dtKM.Rows[0]["QTY1"].ToString(); if (dtKM.Rows[0]["Method"].ToString() == "25") { r["GiaKM"] = dtKM.Rows[0]["DISCPRICE"].ToString(); r["ThanhTien"] = txtsoluong.Value * Convert.ToDecimal(r["GiaKM"]); } else if (dtKM.Rows[0]["Method"].ToString() == "2") { r["ThanhTien"] = (int)(txtsoluong.Value / Int32.Parse(Convert.ToDecimal(dtKM.Rows[0]["QTY1"]).ToString("N0"))) * Convert.ToDecimal(dtKM.Rows[0]["DISCPRICE"].ToString()) + (int)(txtsoluong.Value % Int32.Parse(Convert.ToDecimal(dtKM.Rows[0]["QTY1"]).ToString("N0"))) * Convert.ToDecimal(r["GiaGoc"]); r["GhiChu"] = "Mua SL " + dtKM.Rows[0]["QTY1"].ToString() + " co gia " + Convert.ToDecimal(dtKM.Rows[0]["DISCPRICE"]).ToString("N0"); } } else { r["GiaKM"] = r["GiaGoc"]; r["ThanhTien"] = Convert.ToDecimal(r["GiaGoc"]) * txtsoluong.Value; } _dsSKU.Rows.Add(r); _dsSKUAdd.Add((sku != string.Empty) ? sku : upc, _indexadd++); clearData(); txtSKU.Focus(); GrDSSKU.DataSource = _dsSKU; }
private void BTHienthi_Click(object sender, EventArgs e) { WaitingMsg waitingMsg = new WaitingMsg("Chương trình đang load dữ liệu!", "Please Waiting ......."); try { _tbDSGia.Clear(); copyfile(Config._pathfileWinDSS); //TPSDataAccess access = new TPSDataAccess(Path.Combine(CTLConfig._pathfileWinDSS, "INVMST")); TPSDataAccess access = new TPSDataAccess(_PathFileINVMST); TPSDataAccess accessPathWSS = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, "SYSMST")); SQLHelper helper = new SQLHelper(true); string MaST = "0"; MaST = accessPathWSS.getMaSieuthi(); _storeName = MaST; helper.AddParameterToSQLCommand("@STR", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@STR", MaST); if (MaST == "0") { InfoMessage.HienThi("Khong lay duoc StoreNumber " + MaST + " ", "Vui long lien he voi quan tri", "Loi Get StoreNumber", HinhAnhThongBao.LOI, NutThongBao.DONGY); return; } string strconf = ""; string strsale = ""; string strupc = ""; if (!radConfirAll.Checked) { strconf = " and CONF_PRICE=" + (radconfirYes.Checked ? "'Y'" : "'N'"); helper.AddParameterToSQLCommand("@ISTYPE", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@ISTYPE", (radconfirNo.Checked) ? "01" : "CS"); } if (!radsaleAll.Checked) { strsale = " and SELL_UNIT=" + (radsaleEA.Checked ? "'EA'" : "'KG'"); helper.AddParameterToSQLCommand("@ISLUM", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@ISLUM", (radsaleKG.Checked) ? radsaleKG.Text : radsaleEA.Text); } if (!radUPCALL.Checked) { strupc = " and UPC<>''"; helper.AddParameterToSQLCommand("@ISUPC", SqlDbType.NVarChar, 8); helper.SetSQLCommandParameterValue("@ISUPC", 1); } DataTable dt = helper.GetDatatableBySP("PRLN_spGetPricebyStore"); string sql = string.Format("Select SKU,Price,Description from INVMST where 1=1 {0}{1}{2} order by SKU", strconf, strsale, strupc); DataTable tbg = access.GetDataTable(sql); int dem = 0; foreach (DataRow dataRow in dt.Rows) { decimal p = Convert.ToDecimal(dataRow["PLNITM"].ToString()); for (int i = dem; i < tbg.Rows.Count; i++) { decimal pMMS = Convert.ToDecimal(tbg.Rows[i]["SKU"].ToString()); if (p == pMMS) { if (Convert.ToDecimal(tbg.Rows[i]["Price"]) != Convert.ToDecimal(dataRow["PLNAMT"].ToString())) { DataRow r = _tbDSGia.NewRow(); r["SKU"] = "00" + dataRow["PLNITM"].ToString(); r["Check"] = false; r["Description"] = tbg.Rows[i]["Description"].ToString(); r["Price"] = Convert.ToDecimal(dataRow["PLNAMT"].ToString()); r["PriceMMS"] = Convert.ToDecimal(tbg.Rows[i]["Price"]); _tbDSGia.Rows.Add(r); } dem = i + 1; break; } else if (pMMS > p) { dem = i; break; } } } GrDSPriceSKU.DataSource = _tbDSGia; waitingMsg.Finish(); } catch (Exception exception) { CTLError.WriteError("btLoadData ", exception.Message); waitingMsg.Finish(); return; throw; } }
public void ImPort_Excel() { DataTable dt = new DataTable(); try { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "*.xls|*.xls|*.xlsx|*.xlsx"; TOOLChuyenDuLieu.HelpFile.CTLImportExcel excel = new TOOLChuyenDuLieu.HelpFile.CTLImportExcel(); if (dialog.ShowDialog() == DialogResult.OK) { FileInfo file = new FileInfo(dialog.FileName); if (file.Extension.ToString().Trim().ToUpper() == ".XLS") { dt = excel.getDataFromXLS(dialog.FileName); } else if (file.Extension.ToString().Trim().ToUpper() == ".XLSX") { dt = excel.getDataFromXLS2007(dialog.FileName); } int dem = 0; foreach (DataColumn col in dt.Columns) { if (col.ColumnName.ToUpper() == "CUSTID") { dem++; } } if (dem == 0) { return; } DataTable table = KhoitaoDSPriceBook(); if (dt.Rows.Count >= 1) { foreach (DataRow row in dt.Rows) { DataRow dataRow = table.NewRow(); dataRow["CUSTID"] = row["CUSTID"].ToString(); dataRow["PRICEBOOK"] = row["PRICEBOOK"].ToString(); dataRow["DATE"] = row["DATE"].ToString(); TPSDataAccess access = new TPSDataAccess("H:\\Data\\CUST.pts"); DataTable source = access.GetTableDM(@"Select MCUSTNUM,Pricecategory from CUST where 1=1 and MCUSTNUM=" + row["CUSTID"].ToString()); if (source == null) { dataRow["Check"] = true; } else if (source.Rows.Count == 0) { dataRow["Check"] = true; } else { if (source.Rows[0]["Pricecategory"].ToString().Trim() != row["PRICEBOOK"].ToString().Trim()) { dataRow["Check"] = true; } else { dataRow["Check"] = false; } dataRow["Pricecategory"] = source.Rows[0]["Pricecategory"].ToString(); } table.Rows.Add(dataRow); } } GrDSPriceSKU.DataSource = table; } } catch (Exception ex) { CTLError.WriteError("FrmImportfile ImportExcel", ex.Message); return; throw new Exception(ex.Message); } }
public void LoadPromo(string sku) { if (_sku == string.Empty) { return; } string masku = txtsku.Text; if (txtsku.Text.Length <= 7) { masku = "00" + txtsku.Text; } else if (txtsku.Text.Length > 9) { if (txtsku.Text.Length <= 14) { masku = GetSKU(PhatSinhUPC.Substring(0, 18 - txtsku.Text.Length) + txtsku.Text); } else { masku = GetSKU(txtsku.Text); } } TPSDataAccess access = new TPSDataAccess(Path.Combine(Config._pathfileWinDSS, this._pathFileGia)); DataTable dt = access.GetDataTable_gia((@"Select SKU,MeThod,Start,Stop,Qty1,DiscPrice,Code,Prc_Key ,Price,Pricetype from INVEVT where 1=1 and Method in (2,25,20,21,22) and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + @" >= Start and " + (Math.Round(DateTime.Now.ToOADate()) + _Const_datetime) + " <= stop " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + masku + "'")) ); //DataTable dt = access.GetDataTable_gia(("Select SKU,MeThod,START,Stop,Qty1,DiscPrice from INVEVT where 1=1 and Method in (2,25) " + ((txtsku.Text == string.Empty) ? "" : " and SKU='" + txtsku.Text + "'")), dETuNgay.DateTime, dEDenNgay.DateTime); if (dt.Rows.Count > 0) { tbM2.Rows.Clear(); tbM25.Rows.Clear(); tbM20.Rows.Clear(); tbM21.Rows.Clear(); tbM22.Rows.Clear(); dt = Fixtable(dt); gridControl1.DataSource = dt; gridView1.ExpandAllGroups(); innitgrid(); if (tbM2.Select("MeThod=2").Length >= 1) { DataRow row; if (tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM2.Select("MeThod=2 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM2.Select("MeThod=2 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; labGiaKMTL.Text = "Khi mua với SL " + Convert.ToInt32(row["Qty1"]).ToString("N0") + " giá tiền là " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2"); //+ " Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); } else { labGiaKMTL.Text = "Không có giảm giá theo lượng"; //panel2.Visible = false; //labslKMTL.Text = "0"; } if (tbM25.Select("MeThod=25").Length >= 1) { DataRow row; if (tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM25.Select("MeThod=25 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM25.Select("MeThod=25 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel1.Visible = true; labgiapos.Text = " " + Convert.ToDecimal(row["Price"]).ToString("N2");// +" Từ: " + Convert.ToDateTime(row["Start"]).ToString("dd/MM/yyyy") + " Đến:" + Convert.ToDateTime(row["Stop"]).ToString("dd/MM/yyyy"); //labslpos.Text = "1"; } else { labgiapos.Text = "Không có khuyến mãi tại POS"; //panel1.Visible = false; //labslpos.Text = "0"; } #region khuyen mai theo so gia bool daApDungSoGia = false; if (tbM20.Select("MeThod=20").Length >= 1) { DataRow row; if (tbM20.Select("MeThod=20 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM20.Select("MeThod=20 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM20.Select("MeThod=20 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM20.Select("MeThod=20 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; labelKMSoGia.Text = "Sổ giá giảm theo %(MeThod 20): " + row["Pricetype"].ToString() + " Giảm giá: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " % So với giá bán "; //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } else if (!daApDungSoGia) { labelKMSoGia.Text = "Không giảm giá theo sổ giá"; //panel2.Visible = false; //labslKMTL.Text = "0"; } if (tbM21.Select("MeThod=21").Length >= 1) { DataRow row; if (tbM21.Select("MeThod=21 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM21.Select("MeThod=21 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM21.Select("MeThod=21 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM21.Select("MeThod=21 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; labelKMSoGia.Text = "Sổ giá giảm theo %(MeThod 21): " + row["Pricetype"].ToString() + " Giá khuyến mãi tại POS: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N0") + " "; //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } else if (!daApDungSoGia) { labelKMSoGia.Text = "Không giảm giá theo sổ giá"; //panel2.Visible = false; //labslKMTL.Text = "0"; } if (tbM22.Select("MeThod=22").Length >= 1) { DataRow row; if (tbM22.Select("MeThod=22 and Prc_Key=Min(Prc_Key)").Length == 1) { row = tbM22.Select("MeThod=22 and Prc_Key=Min(Prc_Key)")[0]; } else { Int32 prc_key = Convert.ToInt32(tbM22.Select("MeThod=22 and Prc_Key=Min(Prc_Key)")[0]["Prc_key"]); row = tbM22.Select("MeThod=22 and Prc_Key=" + prc_key + " and Code=max(Code)")[0]; } //panel2.Visible = true; labelKMSoGia.Text = "Sổ giá giảm theo %(MeThod 22): " + row["Pricetype"].ToString() + " Giá giảm: " + Convert.ToDecimal(row["DiscPrice"]).ToString("N2") + " So với giá bán "; //labslKMTL.Text = Convert.ToInt32(row["Qty1"]).ToString("N0"); daApDungSoGia = true; } else if (!daApDungSoGia) { labelKMSoGia.Text = "Không giảm giá theo sổ giá"; //panel2.Visible = false; //labslKMTL.Text = "0"; } #endregion } else { gridControl1.DataSource = null; //panel2.Visible = false; //panel1.Visible = false; //innitgrid(); } }