Esempio n. 1
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            ProductService  service = new ProductService();
            Product product  = null;
            DocCheckProductDetail docCheckProductDetail = new DocCheckProductDetail();

            if (this.docCheckProduct != null)
            {
                docCheckProductDetail.DocCheckProduct = this.docCheckProduct;
                mc4.DocCheckProduct _docCheckProduct = new mc4.DocCheckProduct();
                _docCheckProduct = new DocCheckProduct();
                _docCheckProduct = service.getDocCheckProductByCode(this.docCheckProduct.Code);
                if (_docCheckProduct == null)
                {
                    bool saveDocCheck = service.saveDocCheckProduct(this.docCheckProduct);
                    if (saveDocCheck)
                    {
                        Console.WriteLine("Save Compate :");
                    }
                }

            }
            else {
                MessageBox.Show("��س����͡�Ţ����͡��� !!! ", "����͹");
                return;
            }

            if (!(this.txtBarCode.Text.Trim().Equals("")))
            {
                  product = service.getByBarCode(this.txtBarCode.Text.Trim());
                  if (product != null)
                  {
                      docCheckProductDetail.Product = product;
                  }

            }
            else
            {
                MessageBox.Show("��س����͡������ !!! ", "����͹");
                txtBarCode.Focus();
                return;
            }

            if (!(this.txtNumber.Text.Trim().Equals("")))
            {

                docCheckProductDetail.DocCheckProduct = this.docCheckProduct;
                docCheckProductDetail.Product = product;
                docCheckProductDetail.NumProduct = Convert.ToInt32(this.txtNumber.Text.Trim());
                bool save = service.saveDocCheckProductDetail(docCheckProductDetail);
                if (save)
                {
                    //MessageBox.Show("�ѹ�֡���º����  !!! ", "����͹");
                    lblmsg.Visible = true;
                    lblmsg.Text = "�ѹ�֡���º��������";
                    clearData();
                    Console.WriteLine("Save Compate :");
                }

            }
            else
            {
                MessageBox.Show("��س����͡��͡�ӹǹ�Ѻ  !!! ", "����͹");
                txtNumber.Focus();
                return;
            }
        }
Esempio n. 2
0
        private void cmdimport_Click(object sender, EventArgs e)
        {
            txtmsg.Visible = true;
            string line;
            IList<Product> products = new List<Product>();

            try
            {
                if (!txtpath.Text.Equals(""))
                {

                    if (File.Exists(path))
                    {

                        txtmsg.Text = "���ѧ�Ӣ�������� .........";
                        StreamReader file = null;
                        try
                        {
                            file = new StreamReader(path, Encoding.GetEncoding("windows-874"));
                            int i = 0;
                            Product product = null;
                            ProductService service = new ProductService();
                            int j = 1;
                            int count = 0;
                            int x = 0;
                            while ((line = file.ReadLine()) != null)
                            {
                                if (i != 0)
                                {
                                    string[] words = line.Split('\t');
                                    product = new Product();
                                    product.Code = words[0];
                                    product.BarCode = words[1];
                                    product.Name = words[2];
                                    product.Unit = words[3];
                                    product.Price1 = words[4];
                                    product.Price3 = words[5];
                                    product.Price4 = words[6];
                                    if (words[7] != null && !words[7].Equals(""))
                                    {
                                        product.CreateDate = Convert.ToDateTime(words[7]);
                                    }

                                    this.pBar1.Visible = true;
                                    this.pBar1.Value = x;
                                    x += 10;
                                    if (x > 100) x = 0;

                                    Product _product = service.getByBarCode(product.BarCode);

                                    if (_product == null)
                                    {

                                        bool save = service.saveProduct(product);
                                        if (save)
                                        {
                                            Console.WriteLine("Save Compate :" + product.ID);
                                            txtmsg.Visible = true;
                                            txtmsg.Text = "�Ӣ�������� ���º���� �ӹǹ : " + j + " ��¡��";
                                            j++;
                                        }
                                        else
                                        {
                                            Console.WriteLine("Save Not  Compate :" + product.ID);
                                        }

                                    }
                                    else if (checkdate(_product.CreateDate, product.CreateDate) == false)
                                    {

                                        // update
                                        bool update = service.updateProduct(product);
                                        if (update)
                                        {
                                            Console.WriteLine("update Compate :" + product.ID);
                                            txtmsg.Visible = true;
                                            txtmsg.Text = "�Ӣ�������� ���º���� �ӹǹ : " + j + " ��¡��";
                                            j++;
                                        }
                                        else
                                        {
                                            Console.WriteLine("update Not  Compate :" + product.ID);
                                        }

                                    }
                                    count++;

                                    //products.Add(product);
                                }
                                Console.WriteLine(line);
                                Console.WriteLine(i);
                                i++;

                            }

                            // insert product
                            //ProductService service = new ProductService();

                            //int j = 1;
                            //int count = 0;
                            //int x = 0;
                            //foreach (Product p in products)
                            //{
                            //    this.pBar1.Visible = true;
                            //    this.pBar1.Value = x;
                            //    x += 10;
                            //    if (x > 100) x = 0;

                            //    Product _product = service.getByBarCode(p.BarCode);

                            //    if (_product == null )
                            //    {
                            //        //DateTime cdate = _product.CreateDate;

                            //        bool save = service.saveProduct(p);
                            //        if (save)
                            //        {
                            //            Console.WriteLine("Save Compate :" + p.ID);
                            //            txtmsg.Visible = true;
                            //            txtmsg.Text = "�Ӣ�������� ���º���� �ӹǹ : " + j + " ��¡��";
                            //            j++;
                            //        }
                            //        else
                            //        {
                            //            Console.WriteLine("Save Not  Compate :" + p.ID);
                            //        }

                            //    }
                            //    else if (checkdate(_product.CreateDate, p.CreateDate) == false) {

                            //        // update
                            //        bool update = service.updateProduct(p);
                            //        if (update)
                            //        {
                            //            Console.WriteLine("update Compate :" + p.ID);
                            //            txtmsg.Visible = true;
                            //            txtmsg.Text = "�Ӣ�������� ���º���� �ӹǹ : " + j + " ��¡��";
                            //            j++;
                            //        }
                            //        else
                            //        {
                            //            Console.WriteLine("update Not  Compate :" + p.ID);
                            //        }

                            //    }
                            //    count++;

                            //}

                            if (count == products.Count)
                            {
                                this.pBar1.Value = 0;
                                this.pBar1.Visible = false;
                            }
                            else if (count == 0)
                            {
                                this.pBar1.Value = 0;
                                this.pBar1.Visible = false;
                            }

                            txtmsg.Text = "�Ӣ�������� ������  : " + (j - 1) + " ��¡��";

                        }
                        finally
                        {
                            if (file != null)
                                file.Close();
                        }
                    }
                    else {

                        txtmsg.Text = "�к���辺�����س���͡!!!";
                    }

                }
                else {

                    MessageBox.Show("��س����͡�������Ѻ�Ӣ�������� !!! ", "����͹");

                }

            }
            catch (Exception ex)
            {
                txtmsg.Visible = true;
                txtmsg.Text = "�������ö�Ӣ���������� ���ͧ�ҡ " + ex.Message;

            }
        }
Esempio n. 3
0
        private void textBox1_GotFocus(object sender, EventArgs e)
        {
            string x = textBox1.Text;
            if (x == "1")
            {

                string barcode = "";
                if (!txtBarCode.Text.Trim().Equals(""))
                {
                    barcode = txtBarCode.Text.Trim();
                }

                ProductService service = new ProductService();
                Product product = service.getByBarCode(barcode);

                if (product != null)
                {
                    txtPName.Text = product.Name;
                    lblUnit.Text = product.Unit;
                    lblmsg.Visible = false;
                    txtNumber.Focus();
                }
                else {
                    txtPName.Text ="";
                    lblUnit.Text = "";
                    lblmsg.Visible = true;
                    lblmsg.Text = "��辺������";
                    txtBarCode.Focus();
                }

            }
        }