Пример #1
0
        private void AddPLURow(Product p)
        {
            if (dgvPLUDefine.Rows.Count % 10 == 0)
            {
                Application.DoEvents();
            }

            int index = dgvPLUDefine.Rows.Add();
            dgvPLUDefine.Rows[index].Cells[clmnPLUNo.Index].Value = p.PluNo;
            dgvPLUDefine.Rows[index].Cells[clmnPLUName.Index].Value = p.Name;
            dgvPLUDefine.Rows[index].Cells[clmnPLUDeptNo.Index].Value = p.Department;
            dgvPLUDefine.Rows[index].Cells[clmnPLUPrice.Index].Value = p.Price.ToString("#0.00");
            ((DataGridViewCheckBoxCell)dgvPLUDefine.Rows[index].Cells[clmnPLUWeighable.Index]).Value = (bool)(p.Weighable == 1);
            dgvPLUDefine.Rows[index].Cells[clmnPLUBarcode.Index].Value = p.Barcode;
            dgvPLUDefine.Rows[index].Cells[clmnPLUSubCat.Index].Value = p.SubCategory;
        }
Пример #2
0
        private void btnGetPLU_Click(object sender, EventArgs e)
        {
            Product p = null;
            try
            {
                dgvPLUDefine.Rows.Clear();

                CPResponse response = null;
                string[] splittedValues = txtPluAddress.Text.Split(new char[] { ',' });
                foreach (String value in splittedValues)
                {
                    if (value.Contains("-"))
                    {
                        string[] spltRange = value.Split(new char[] { '-' });
                        int first = int.Parse(spltRange[0]);
                        int end = int.Parse(spltRange[1]);

                        for (int i = first; i <= end; i++)
                        {
                            response = new CPResponse(bridge.Printer.GetProduct(i));

                            if (response.ErrorCode == 0)
                            {
                                p = new Product();
                                p.PluNo = i;
                                p.Name = response.GetNextParam();
                                p.Department = int.Parse(response.GetNextParam());
                                p.Price = decimal.Parse(response.GetNextParam());
                                p.Weighable = int.Parse(response.GetNextParam());
                                p.Barcode = response.GetNextParam();
                                p.SubCategory = int.Parse(response.GetNextParam());

                                AddPLURow(p);
                            }
                        }
                    }
                    else
                    {
                        response = new CPResponse(bridge.Printer.GetProduct(int.Parse(value)));

                        if (response.ErrorCode == 0)
                        {
                            p = new Product();
                            p.PluNo = Convert.ToInt32(value);
                            p.Name = response.GetNextParam();
                            p.Department = int.Parse(response.GetNextParam());
                            p.Price = decimal.Parse(response.GetNextParam());
                            p.Weighable = int.Parse(response.GetNextParam());
                            p.Barcode = response.GetNextParam();
                            p.SubCategory = int.Parse(response.GetNextParam());

                            AddPLURow(p);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                bridge.Log(FormMessage.PRODUCT_COULD_NOT_BE_READ + " " + ex.Message);
            }
        }
Пример #3
0
        private void btnSavePLU_Click(object sender, EventArgs e)
        {
            DataGridViewCheckBoxCell selectedCell;
            for (int i = 0; i < dgvPLUDefine.Rows.Count; i++)
            {
                try
                {
                    selectedCell = (DataGridViewCheckBoxCell)dgvPLUDefine.Rows[i].Cells[clmnPLUSelected.Index];
                    if (selectedCell.Value != null && (bool)selectedCell.Value == true)
                    {
                        List<byte> bytes = new List<byte>();
                        //PRODUCT ID
                        int pluNo = Convert.ToInt32(dgvPLUDefine.Rows[i].Cells[clmnPLUNo.Index].Value);

                        //NAME
                        String pluName = (String)dgvPLUDefine.Rows[i].Cells[clmnPLUName.Index].Value;

                        //DEPT ID
                        int deptId = Convert.ToInt32(dgvPLUDefine.Rows[i].Cells[clmnPLUDeptNo.Index].Value);

                        //PRICE
                        decimal price = Convert.ToDecimal(dgvPLUDefine.Rows[i].Cells[clmnPLUPrice.Index].Value);

                        //WEIGHABLE
                        selectedCell = (DataGridViewCheckBoxCell)dgvPLUDefine.Rows[i].Cells[clmnPLUWeighable.Index];
                        int weighable = 0;
                        if (selectedCell.Value != null && ((bool)selectedCell.Value))
                        {
                            weighable = 1;
                        }

                        //BARCODE
                        String barcode = (String)dgvPLUDefine.Rows[i].Cells[clmnPLUBarcode.Index].Value;

                        //SUB CAT ID
                        int subCatId = Convert.ToInt32(dgvPLUDefine.Rows[i].Cells[clmnPLUSubCat.Index].Value);

                        // Send Department Command
                        CPResponse response = new CPResponse(bridge.Printer.SaveProduct(pluNo, pluName, deptId,
                                                    price, weighable, barcode, subCatId));

                        if (response.ErrorCode == 0)
                        {
                            Product p = new Product();
                            p.Name = response.GetNextParam();
                            p.Department = int.Parse(response.GetNextParam());
                            p.Price = decimal.Parse(response.GetNextParam());
                            p.Weighable = int.Parse(response.GetNextParam());
                            p.Barcode = response.GetNextParam();
                            p.SubCategory = int.Parse(response.GetNextParam());

                            bridge.Log(String.Format("{6}:{0,-20} {7}: {1,2} {8}: {2:#0.00} {9}:{3} {10}: {4,-20} {11}:{5}",
                                p.Name,
                                p.Department,
                                p.Price,
                                p.Weighable == 1 ? "E" : "H",
                                p.Barcode,
                                p.SubCategory,
                                FormMessage.PLU_NAME,
                                FormMessage.DEPARTMENT_ID,
                                FormMessage.PRICE,
                                FormMessage.WEIGHABLE,
                                FormMessage.BARCODE,
                                FormMessage.SUB_CATEGORY));
                        }
                    }
                }
                catch (Exception ex)
                {
                    bridge.Log(FormMessage.PRODUCT_COULD_NOT_BE_SAVED + " " + ex.Message);
                }
            }
        }