Exemplo n.º 1
0
        private void cmdClearData_Click(object sender, EventArgs e)
        {
            try
            {
                ProductService service = new ProductService();

                bool delete = service.deteData();
                if (delete)
                {
                    lblresultdb.Visible = true;
                    lblresultdb.Text = "ź���������º��������";

                }
                else {
                    lblresultdb.Visible = true;
                    lblresultdb.Text = "�������öź�������� ���ͧ�ҡ ";
                }

            }
            catch (Exception ex) {

                lblresultdb.Visible = true;
                lblresultdb.Text = "�������öź�������� ���ͧ�ҡ "+ex.Message;

            }
        }
Exemplo n.º 2
0
        private void cmdbeginCheck_Click(object sender, EventArgs e)
        {
            DocCheckProduct docCheckProduct = null;
            if (ibarcode.Equals("")) {
                docCheckProduct = new DocCheckProduct();
            }else {
                ProductService service  = new ProductService();
                docCheckProduct =service.getDocCheckProductByCode(ibarcode);

                txtPCode.Text = docCheckProduct.Code;
                txtWarehouse.Text = docCheckProduct.Warehouse;
                txtLocation.Text = docCheckProduct.Location;

            }

            if (!txtPCode.Text.Trim().Equals(""))
            {
                docCheckProduct.Code = txtPCode.Text.Trim();
            }
            else {
                MessageBox.Show("��س����͡��͡�Ţ����͡��� !!! ", "����͹");
                txtPCode.Focus();
                return;
            }

            if (!txtWarehouse.Text.Trim().Equals(""))
            {
                docCheckProduct.Warehouse = txtWarehouse.Text.Trim();
            }
            else
            {
                MessageBox.Show("��س����͡��͡��ѧ�Թ��� !!! ", "����͹");
                txtWarehouse.Focus();
                return;
            }
            if (!txtLocation.Text.Trim().Equals(""))
            {
                docCheckProduct.Location = txtLocation.Text.Trim();
            }
            else
            {
                MessageBox.Show("��س����͡��͡ʶҹ��� !!! ", "����͹");
                txtLocation.Focus();
                return;
            }

            frmDocCheckP21 _frmDocCheckP21 = new frmDocCheckP21(docCheckProduct);
            _frmDocCheckP21.Show();
            this.Hide();
        }
Exemplo n.º 3
0
        private void cmdsearch_Click(object sender, EventArgs e)
        {
            try
            {

                ProductService service = new ProductService();
                IList<DocCheckProduct> docCheckProducts = new List<DocCheckProduct>();
                docCheckProducts = service.getDocCheckProductByDCode(this.txtSearch.Text.Trim());

                DataTable table = new DataTable();

                if (docCheckProducts != null && docCheckProducts.Count != 0)
                {

                    table = GetTable(docCheckProducts);
                    DataSet ds = new DataSet();
                    ds.Tables.Add(table);

                    dataGrid1.DataSource = ds.Tables["DocCheckProduct"];
                    FormatDgvProduct();
                    label2.Visible = true;
                    label2.Text = "�ӹǹ���鹾� :" + docCheckProducts.Count + " ��¡��";
                }
                else
                {
                    MessageBox.Show("��辺������ !!! ", "����͹");

                    IList<DocCheckProduct> docCheckProductsnull = new List<DocCheckProduct>();
                    table = GetTable(docCheckProductsnull);
                    label2.Visible = false;
                    label2.Text = "�ӹǹ���鹾� : 0 ��¡��";
                    DataSet ds = new DataSet();
                    ds.Tables.Add(table);

                    dataGrid1.DataSource = ds.Tables["DocCheckProduct"];
                    FormatDgvProduct();

                }

            }
            catch (Exception ex)
            {

            }
        }
Exemplo n.º 4
0
        private void frmNewCheckP2_Load(object sender, EventArgs e)
        {
            if (!ibarcode.Equals(""))
            {
                ProductService service = new ProductService();
                DocCheckProduct docCheckProduct = service.getDocCheckProductByCode(ibarcode);

                txtPCode.Text = docCheckProduct.Code;
                txtPCode.Enabled = false;
                txtWarehouse.Text = docCheckProduct.Warehouse;
                txtWarehouse.Enabled = false;
                txtLocation.Text = docCheckProduct.Location;
                txtLocation.Enabled = false;
            }
        }
Exemplo n.º 5
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;

            }
        }
Exemplo n.º 6
0
        private void FormTest_Load(object sender, EventArgs e)
        {
            ProductService service = new ProductService();
            docCheckProductDetails = service.getDocCheckProductDetailByDCode("1");
            table = GetTable(docCheckProductDetails);
               DataSet ds = new DataSet();
               ds.Tables.Add(table);
               dataGrid2.DataSource = ds.Tables["DocCheckProductDetails"];
               //FormatDgvProduct2();
               TotalRecord = docCheckProductDetails.Count;
               double tmpPageCount = (double)TotalRecord / PageSize;
               PageCount = Convert.ToInt32(Math.Ceiling(tmpPageCount));

               tsRecordCount.Text = TotalRecord.ToString() + " ��¡��";
               CurrentPage = 1;
               RecordToDisplay = 0;

               ShowRecord(CurrentPage);

            FormatDgvProduct();
        }
Exemplo n.º 7
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;
            }
        }
Exemplo n.º 8
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();
                }

            }
        }
Exemplo n.º 9
0
        private void loadData()
        {
            try
            {
                ProductService service = new ProductService();
                IList<DocCheckProduct> docCheckProducts = new List<DocCheckProduct>();
                docCheckProducts = service.getDocCheckProductAll();

                DataTable table = new DataTable();

                if (docCheckProducts != null && docCheckProducts.Count != 0)
                {

                    table = GetTable(docCheckProducts);
                    DataSet ds = new DataSet();
                    ds.Tables.Add(table);

                    dataGrid1.DataSource = ds.Tables["DocCheckProduct"];
                    FormatDgvProduct();
                    label2.Visible = true;
                    label2.Text = "�ӹǹ���鹾� :" + docCheckProducts.Count + " ��¡��";
                }
                else
                {

                        IList<DocCheckProduct> docCheckProductsnull = new List<DocCheckProduct>();
                        table = GetTable(docCheckProductsnull);
                        label2.Visible = false;
                        label2.Text = "�ӹǹ���鹾� : 0 ��¡��";
                        DataSet ds = new DataSet();
                        ds.Tables.Add(table);

                        dataGrid1.DataSource = ds.Tables["DocCheckProduct"];
                        FormatDgvProduct();

                }

            }
            catch (Exception ex)
            {

            }
        }
Exemplo n.º 10
0
        private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
        {
            string dCode = string.Empty;
            int row = dataGrid1.CurrentRowIndex;
            int col = dataGrid1.CurrentCell.ColumnNumber;

            int iRow;
            int iCol;
            DataTable myTable;
            bool gotoback = false;

            myTable = (DataTable)dataGrid1.DataSource;
            for (iRow = 0; iRow < myTable.Rows.Count; iRow++)
            {
                if (row == iRow)
                {
                    for (iCol = 0; iCol < myTable.Columns.Count; iCol++)
                    {
                        dCode = Convert.ToString(dataGrid1[iRow, 1]);

                        break;

                    }
                }

            }

            if (col == 2) {

                ProductService productService = new ProductService();

                DocCheckProduct docCheckProduct = productService.getDocCheckProductByCode(dCode);
                IList<DocCheckProductDetail> docCheckProductDetail = productService.getDocCheckProductDetailByDCode(dCode);

                IList<ProductExport> productExports = new List<ProductExport>();
                ProductExport productExport;

                /*
                productExport = new ProductExport();
                productExport.DCode = "�Ţ����͡���";
                productExport.PCode = "���ʺ�����";
                productExport.PName = "�����Թ���";
                productExport.WereHouse = "��ѧ�Թ���";
                productExport.Location = "ʶҹ���";
                productExport.Blank = "��ҧ";
                productExport.Number = "�ӹǹ�Ѻ";
                productExports.Add(productExport);*/

                foreach (DocCheckProductDetail d in docCheckProductDetail)
                {
                    productExport = new ProductExport();

                    productExport.WereHouse = docCheckProduct.Warehouse;// ��ѧ�Թ���
                    productExport.Location = docCheckProduct.Location; // ʶҹ���
                    productExport.DCode = docCheckProduct.Code; // �����͡����
                    if (d != null)
                    {
                        if (d.Product != null)
                        {
                            productExport.PCode = d.Product.BarCode; // ���ʺ�����
                            productExport.PName = d.Product.Name;
                            productExport.Blank = "";
                            productExport.Unit = d.Product.Unit;// ˹��¹Ѻ
                        }

                        productExport.Number = Convert.ToString(d.NumProduct);
                    }
                    productExports.Add(productExport);

                }
                string[] rowString = new string[docCheckProductDetail.Count + 1];

                /*
                string path = Path.GetDirectoryName(
               Assembly.GetExecutingAssembly().GetName().CodeBase) +
               "\\exportdata\\" + productExports[row].DCode + ".txt";*/

                configDoc.Load(DbConnect.pathconfig);
                XmlNode nod = configDoc.GetElementsByTagName("add")[2];
                string filePath = nod.Attributes["value"].Value;

                string path = filePath + dCode + ".txt";

                File.Delete(path);

                int i = 0;
                foreach (ProductExport p in productExports)
                {
                    rowString[i] = p.DCode + "\t";
                    rowString[i] += p.PCode + "\t";
                    //rowString[i] += p.PName + "\t";
                    rowString[i] += p.WereHouse + "\t";
                    rowString[i] += p.Location + "\t";
                    rowString[i] += p.Unit + "\t";
                    rowString[i] += p.Number;

                    using (StreamWriter writer = new StreamWriter(path, true))
                    {
                        writer.WriteLine(rowString[i]);

                    }

                    i++;
                }

                if (productExports.Count == i)
                {
                    MessageBox.Show("�Ӣ������͡���º�������� !!! ", "����͹");
                }

            }
        }
Exemplo n.º 11
0
 private void frmTest3_Load(object sender, EventArgs e)
 {
     ProductService service = new ProductService();
     docCheckProductDetails = service.getDocCheckProductDetailByDCode("1");
     table = GetTable(docCheckProductDetails);
     DataSet ds = new DataSet();
     ds.Tables.Add(table);
     dataGrid1.DataSource = ds.Tables["DocCheckProductDetails"];
     FormatDgvProduct();
 }
Exemplo n.º 12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //bool used = checkPermission();
            bool used = true;

            if (used == false)
            {
                MessageBox.Show("��سҵ�Ǩ�ͺ�Է�ԡ�������������!!! ", "����͹");
                Application.Exit();
            }
            else {

                try
                {
                    ProductService service = new ProductService();
                    checkPermission();

                    /*
                         string pathconfig = Path.GetDirectoryName(
                       Assembly.GetExecutingAssembly().GetName().CodeBase) +
                       "\\Config.xml";*/
                        //lblconfig.Text = DbConnect.pathconfig;
                        // Product product = service.getById(1);

                }
                catch (Exception ex)
                {
                    //lblmsg.Text = "�������ö�Դ��Ͱҹ�������� ���ͧ�ҡ"+ex.Message;
                }

            }
        }
Exemplo n.º 13
0
        private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
        {
            try
                {

            int row = dataGrid1.CurrentRowIndex;
            int col = dataGrid1.CurrentCell.ColumnNumber;

            int iRow;
            int iCol;
            DataTable myTable;
            bool gotoback = false;
            string pname = "";

            myTable = (DataTable)dataGrid1.DataSource;
            for (iRow = 0; iRow < myTable.Rows.Count; iRow++)
            {
                if (row == iRow)
                {
                    for (iCol = 0; iCol < myTable.Columns.Count; iCol++)
                    {

                        dcode = Convert.ToString(dataGrid1[iRow, 2]);
                        pcode = Convert.ToString(dataGrid1[iRow, 3]);
                        num = Convert.ToInt32(dataGrid1[iRow, 1]);
                        pname = Convert.ToString(dataGrid1[iRow, 0]);
                        pid = Convert.ToString(dataGrid1[iRow, 6]);
                        break;

                    }
                }

            }

            if (col == 5)
            {

                if (MessageBox.Show("�س��ͧź�Թ���:" + pname + " ��������� ?", "���׹�ѹ", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    ProductService service = new ProductService();
                    bool deleteDetail = service.deleteDocCheckProductDetail(pid,dcode, pcode);
                    if (deleteDetail)
                    {

                            cmdsearch_Click(sender, e);
                            MessageBox.Show("ź���������º�������� !!! ", "����͹");

                    }

                }
            }
            else {

            }
            checkgrid = true;
            txtNum.Text = Convert.ToString(this.num);
            }
            catch (Exception ex)
            {

            }
            ///
        }
Exemplo n.º 14
0
        private void cmdsave_Click(object sender, EventArgs e)
        {
            if (checkgrid == false) {
                return;
            }

            try
            {
                ProductService service = new ProductService();
                bool savedit = service.editNumberCheckProduct(this.pid,this.dcode, this.pcode,Convert.ToInt32(txtNum.Text.Trim()));
                if (savedit) {
                    //MessageBox.Show("������º���� !!! ", "����͹");
                    Console.WriteLine("Edit Sucsess");
                    cmdsearch_Click(sender, e);
                }
                CurrentPage = cpag;
                if (CurrentPage < 1)
                {
                    CurrentPage = 1;
                    RecordToDisplay = 0;
                }
                else
                {
                    RecordToDisplay = (CurrentPage - 1) * PageSize;
                }

                ShowRecord(CurrentPage);
            }
            catch (Exception ex) {

            }
        }
Exemplo n.º 15
0
        private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
        {
            string barCode = string.Empty;
            int row = dataGrid1.CurrentRowIndex;
            int col = dataGrid1.CurrentCell.ColumnNumber;

            int iRow;
            int iCol;
            DataTable myTable;
            bool gotoback = false;

            myTable = (DataTable)dataGrid1.DataSource;
            for (iRow = 0; iRow < myTable.Rows.Count; iRow++)
            {
                if (row == iRow)
                {
                    for (iCol = 0; iCol < myTable.Columns.Count; iCol++)
                    {
                        barCode = Convert.ToString(dataGrid1[iRow, 1]);

                        break;

                    }
                }

            }

            if (col == 2) {

                if (MessageBox.Show("�س��ͧ���ź�������Ţ��� :" + barCode + " ��������� ?", "���׹�ѹ", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    ProductService service = new ProductService();
                    bool delete = service.deleteDocCheckProduct(barCode);
                    if (delete)
                    {
                        MessageBox.Show("ź���������º�������� !!! ", "����͹");
                        Console.WriteLine(" Delete Sueess");
                        loadData();
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
        }