Exemplo n.º 1
0
        private void button54_Click(object sender, EventArgs e)
        {
            if (myCash1.listInvoiceItem.Rows.Count != 0)
            {
                FrmPay frmPay = new FrmPay();
                frmPay.textBox1.Text = frmPay.textBox2.Text = String.Format("{0:0,0}", Convert.ToDecimal(myCash1.label_Total.Text));
                if (frmPay.ShowDialog() == DialogResult.OK)
                {
                    myCash1.invoiceTotal.Rows[0]["Amt_Tendered"]   = frmPay.tienTra;
                    myCash1.invoiceTotal.Rows[0]["Amt_Change"]     = frmPay.tienThoi;
                    myCash1.invoiceTotal.Rows[0]["Status"]         = "C";
                    myCash1.invoiceTotal.Rows[0]["Payment_Method"] = frmPay.hinhThucTra;
                    if (frmPay.hinhThucTra == "CA")
                    {
                        myCash1.invoiceTotal.Rows[0]["CA_Amount"] = Convert.ToDecimal(myCash1.label_Total.Text);
                    }
                    else if (frmPay.hinhThucTra == "CC")
                    {
                        myCash1.invoiceTotal.Rows[0]["CC_Amount"] = Convert.ToDecimal(myCash1.label_Total.Text);
                    }
                    else if (frmPay.hinhThucTra == "DC")
                    {
                        myCash1.invoiceTotal.Rows[0]["DC_Amount"] = Convert.ToDecimal(myCash1.label_Total.Text);
                    }

                    myCash1.invoiceTotal.Rows[0]["Cashier_ID"] = StaticClass.cashierId;
                    getGui.DeleteInvoiceItemized(StaticClass.storeId, this.invoiceNum);
                    if (myCash1.listInvoiceItem.Rows.Count == 0)
                    {
                        myCash1.invoiceTotal.Rows[0][15] = "V";
                        getGui.CloseTable(StaticClass.storeId, invoiceNum);
                    }
                    else
                    {
                        foreach (DataRow c in myCash1.listInvoiceItem.Rows)
                        {
                            getGui.UpdateInvoiceItemized(StaticClass.storeId, invoiceNum, c[2].ToString(), c[3].ToString(), c[12].ToString(), c[1].ToString(), c[6].ToString(), c[7].ToString(), c[8].ToString(), c[5].ToString(), c[19].ToString());
                        }
                    }
                    UpdateInvoiceTotals();
                    getGui.DeleteInvoiceOnhold(StaticClass.storeId, invoiceNum);
                    SendToKitchen();
                    this.Dispose();
                    formLayout.FrmLayout_Load(null, null);

                    formLogin.RequestMess("UpdateForm");
                    Printer printer = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, "Hóa đơn");
                    if (!(printer == null || printer.Details == "NONE" || printer.Disable == true))
                    {
                        Re_ThanhToan xxx = new Re_ThanhToan();

                        xxx.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true);
                        ParameterFieldDefinitions crParameterFieldDefinitions;
                        ParameterFieldDefinition  crParameterFieldDefinition;
                        ParameterValues           crParameterValues = new ParameterValues();

                        ParameterFieldDefinitions crParameterFieldDefinitions1;
                        ParameterFieldDefinition  crParameterFieldDefinition1;
                        ParameterValues           crParameterValues1        = new ParameterValues();
                        ParameterDiscreteValue    crParameterDiscreteValue  = new ParameterDiscreteValue();
                        ParameterDiscreteValue    crParameterDiscreteValue1 = new ParameterDiscreteValue();


                        crParameterDiscreteValue.Value = StaticClass.storeId;
                        crParameterFieldDefinitions    = xxx.DataDefinition.ParameterFields;
                        crParameterFieldDefinition     = crParameterFieldDefinitions["@Store_ID"];
                        crParameterValues = crParameterFieldDefinition.CurrentValues;

                        crParameterValues.Clear();
                        crParameterValues.Add(crParameterDiscreteValue);
                        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                        crParameterDiscreteValue1.Value = invoiceNum;
                        crParameterFieldDefinitions1    = xxx.DataDefinition.ParameterFields;
                        crParameterFieldDefinition1     = crParameterFieldDefinitions1["@Invoice_Number"];
                        crParameterValues1 = crParameterFieldDefinition1.CurrentValues;

                        crParameterValues1.Clear();
                        crParameterValues1.Add(crParameterDiscreteValue1);
                        xxx.PrintOptions.PrinterName = printer.Details;
                        crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);
                        xxx.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0));
                        xxx.PrintToPrinter(1, false, 0, 0);
                    }
                }
            }
            else
            {
                Alert.Show("Hóa đơn chưa có hàng", Color.Red);
            }
        }
Exemplo n.º 2
0
        private void button54_Click(object sender, EventArgs e)
        {
            
            if(myCash1.listInvoiceItem.Rows.Count != 0)
            {
                FrmPay frmPay = new FrmPay();
                frmPay.textBox1.Text = frmPay.textBox2.Text = String.Format("{0:0,0}", Convert.ToDecimal(myCash1.label_Total.Text));
                if(frmPay.ShowDialog() == DialogResult.OK)
                {
                    myCash1.invoiceTotal.Rows[0]["Amt_Tendered"] = frmPay.tienTra;
                    myCash1.invoiceTotal.Rows[0]["Amt_Change"] = frmPay.tienThoi;
                    myCash1.invoiceTotal.Rows[0]["Status"] = "C";
                    myCash1.invoiceTotal.Rows[0]["Payment_Method"] = frmPay.hinhThucTra;
                    if(frmPay.hinhThucTra == "CA")
                    {
                        myCash1.invoiceTotal.Rows[0]["CA_Amount"] = Convert.ToDecimal(myCash1.label_Total.Text);

                    }
                    else if (frmPay.hinhThucTra == "CC")
                    {
                        myCash1.invoiceTotal.Rows[0]["CC_Amount"] = Convert.ToDecimal(myCash1.label_Total.Text);
                    }
                    else if (frmPay.hinhThucTra == "DC")
                    {
                        myCash1.invoiceTotal.Rows[0]["DC_Amount"] = Convert.ToDecimal(myCash1.label_Total.Text);
                    }

                    myCash1.invoiceTotal.Rows[0]["Cashier_ID"] = StaticClass.cashierId;
                    getGui.DeleteInvoiceItemized(StaticClass.storeId, this.invoiceNum);
                    if (myCash1.listInvoiceItem.Rows.Count == 0)
                    {
                        myCash1.invoiceTotal.Rows[0][15] = "V";
                        getGui.CloseTable(StaticClass.storeId, invoiceNum);
                    }
                    else
                    {
                        foreach (DataRow c in myCash1.listInvoiceItem.Rows)
                        {
                            getGui.UpdateInvoiceItemized(StaticClass.storeId, invoiceNum, c[2].ToString(), c[3].ToString(), c[12].ToString(), c[1].ToString(), c[6].ToString(), c[7].ToString(), c[8].ToString(), c[5].ToString(), c[19].ToString());
                        }
                    }
                    UpdateInvoiceTotals();
                    getGui.DeleteInvoiceOnhold(StaticClass.storeId,invoiceNum);
                    SendToKitchen();
                    this.Dispose();
                    formLayout.FrmLayout_Load(null, null);

                    formLogin.RequestMess("UpdateForm");
                     Printer printer = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, "Hóa đơn");
                     if (!(printer == null || printer.Details == "NONE" || printer.Disable == true))
                     {
                         Re_ThanhToan xxx = new Re_ThanhToan();

                         xxx.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true);
                         ParameterFieldDefinitions crParameterFieldDefinitions;
                         ParameterFieldDefinition crParameterFieldDefinition;
                         ParameterValues crParameterValues = new ParameterValues();

                         ParameterFieldDefinitions crParameterFieldDefinitions1;
                         ParameterFieldDefinition crParameterFieldDefinition1;
                         ParameterValues crParameterValues1 = new ParameterValues();
                         ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
                         ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();


                         crParameterDiscreteValue.Value = StaticClass.storeId;
                         crParameterFieldDefinitions = xxx.DataDefinition.ParameterFields;
                         crParameterFieldDefinition = crParameterFieldDefinitions["@Store_ID"];
                         crParameterValues = crParameterFieldDefinition.CurrentValues;

                         crParameterValues.Clear();
                         crParameterValues.Add(crParameterDiscreteValue);
                         crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                         crParameterDiscreteValue1.Value = invoiceNum;
                         crParameterFieldDefinitions1 = xxx.DataDefinition.ParameterFields;
                         crParameterFieldDefinition1 = crParameterFieldDefinitions1["@Invoice_Number"];
                         crParameterValues1 = crParameterFieldDefinition1.CurrentValues;

                         crParameterValues1.Clear();
                         crParameterValues1.Add(crParameterDiscreteValue1);
                         xxx.PrintOptions.PrinterName = printer.Details;
                         crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);
                         xxx.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0));
                         xxx.PrintToPrinter(1, false, 0, 0);
                     }

                    
                }
            }
            else
            {
                Alert.Show("Hóa đơn chưa có hàng",Color.Red);
            }
        }
Exemplo n.º 3
0
        //private Thread printReceiptThread;
        
        public FrmBanHang()
        {
            InitializeComponent();
            serviceGet = new ServiceGet();
            getGui = new get_GUI();
            frmPay = new FrmPay();
            //for (int i = 1; i < 8;i++ )
            //{
            //    button tmp = (button)panel1.Controls["button" + i.ToString()];
            //    tmp.changeColor(Color.White,Color.Orange);
            //}
            //for (int i = 15; i < 43; i++)
            //{
            //    button tmp = (button)panel2.Controls["button" + i.ToString()];
            //    tmp.changeColor(Color.White, Color.Gray);
            //}
            //button45.changeColor(Color.White,Color.OrangeRed);
            //button46.changeColor(Color.White, Color.OrangeRed);
            //button47.changeColor(Color.White,Color.Orange);
            //button48.changeColor(Color.White, Color.Yellow);
            //button49.changeColor(Color.White, Color.OrangeRed);
            //button50.changeColor(Color.White, Color.Gray);
            //button52.changeColor(Color.White, Color.Gray);
            //button53.changeColor(Color.White, Color.Orange);
            //button54.changeColor(Color.White, Color.Green);

            
            //listNhomHang = new ArrayList();
            
            
            //for (int i = 1; i < 18; i++)
            //{
            //    listNhomHang.Add(i.ToString());
            //}
            //for (int i = 1; i < 70; i++)
            //{
            //    listMatHang.Add(i.ToString());
            //}

            //listMatHang = new ArrayList();
            //listIdNhomHang = new ArrayList();
            //listNhomHang = new ArrayList();
            //listIdMatHang = new ArrayList();
            listTSButtonDept = new ArrayList();
            listTSButtonInvent = new ArrayList();
            DataTable tblnhomhang = serviceGet.GetDepartments("1001");
            for (int i = 0; i < tblnhomhang.Rows.Count; i++)
            {
                //listNhomHang.Add(tblnhomhang.Rows[i][2].ToString());
                //listIdNhomHang.Add(tblnhomhang.Rows[i][24].ToString());
                TSButton tsButton = new TSButton("01", Convert.ToInt32(tblnhomhang.Rows[i]["Index"]),
                 tblnhomhang.Rows[i]["Caption"].ToString(), tblnhomhang.Rows[i]["Picture"].ToString(), tblnhomhang.Rows[i]["Option1"].ToString(),
                 Convert.ToInt32(tblnhomhang.Rows[i]["BackColor"]), Convert.ToInt32(tblnhomhang.Rows[i]["ForeColor"]), Convert.ToBoolean(tblnhomhang.Rows[i]["Visible"]),
                 tblnhomhang.Rows[i]["Ident"].ToString());
                listTSButtonDept.Add(tsButton);
            }

            if(tblnhomhang.Rows.Count > 0)
            {
                DataTable tblMathang = getGui.GetInventoryByDept("0", ((TSButton)listTSButtonDept[0]).Ident, "1001");
                for (int i = 0; i < tblMathang.Rows.Count; i++)
                {
                    //listMatHang.Add(tblMathang.Rows[i][3].ToString());
                    //listIdMatHang.Add(tblMathang.Rows[i][7].ToString());
                    TSButton tsButton = new TSButton("01", Convert.ToInt32(tblMathang.Rows[i]["Index"]),
                     tblMathang.Rows[i]["Caption"].ToString(), tblMathang.Rows[i]["Picture"].ToString(), tblMathang.Rows[i]["Option1"].ToString(),
                     Convert.ToInt32(tblMathang.Rows[i]["BackColor"]), Convert.ToInt32(tblMathang.Rows[i]["ForeColor"]), Convert.ToBoolean(tblMathang.Rows[i]["Visible"]),
                     tblMathang.Rows[i]["Ident"].ToString());
                    listTSButtonInvent.Add(tsButton);
                }

            }
            else
            {
                button8.Visible = false;
            }
            

            if(listTSButtonDept.Count % 7 == 0)
            {
                numOfPageNhom = listTSButtonDept.Count / 7;
            }
            else
            {
                numOfPageNhom = listTSButtonDept.Count / 7 + 1;
                
            }

            if (listTSButtonInvent.Count % 28 == 0)
            {
                numOfPageMatHang = listTSButtonInvent.Count / 28;
            }
            else
            {
                numOfPageMatHang = listTSButtonInvent.Count / 28 + 1;
            }
            pageIndexNhom = 1;
            selectIndexNhom = 1;

            pageIndexMatHang = 1;

            
            LoadNhomHang();
            LoadMatHang();
            ////////////////////////////////////////////////////////////////////////////
            for (int i = 1; i < 8; i++)
            {
                string buttonName = "button" + i.ToString();
                button tmp = (button)panel1.Controls[buttonName];
                tmp.Click += new EventHandler(tmp_Click);
                //tmp.changeColor(Color.White, Color.Orange);
            }
            for (int i = 15; i < 43; i++)
            {
                button tmp1 = (button)panel2.Controls["button" + i.ToString()];
                //tmp1.changeColor(Color.White, Color.Gray);
                tmp1.Click += new EventHandler(tmp1_Click);
            }
            //UpdateInfo();

        }