コード例 #1
0
ファイル: frmBranchMain.cs プロジェクト: itktc/projectktc-v2
 private void smenuProductList_Click(object sender, EventArgs e)
 {
     DataMain.frmProductMain frmProduct = new KTCERP.DataMain.frmProductMain();
     frmProduct.MdiParent = this;
     frmProduct.StartPosition = FormStartPosition.CenterScreen;
     frmProduct.Show();
 }
コード例 #2
0
        public void insertchildproduct( string DatabaseName)
        {
            tr = Conn.BeginTransaction();

            try
            {
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                /*
                if (ProductPhoto != "")
                {
                    fs = new FileStream(ProductPhoto, FileMode.Open, FileAccess.Read);
                    byte[] CurrentImage = new byte[Convert.ToInt32(fs.Length)];
                    fs.Position = 0;
                    fs.Read(CurrentImage, 0, Convert.ToInt32(fs.Length - 1));
                    fs.Close();
                }
                */
                sb.Append("INSERT INTO PRODUCT (ProductId,ProductIdExternal,ProductIdExternal2,ProductParentId,ProductName,");
                sb.Append("ProductNameEng,ProductDescript,MainCateId,SubCateId,UnitChildId,UnitSaleId,UnitStockId,");
                sb.Append("ProductStockConvert,UnitConvertId,ProductStockReorder,ProductPackQuantity,ProductPackWeight,ProductOrderId,UnitPackId)");
                sb.Append(" VALUES (@ProductId,@ProductIdExternal,@ProductIdExternal2,@ProductParentId,@ProductName,");
                sb.Append("@ProductNameEng,@ProductDescript,@MainCateId,@SubCateId,@UnitChildId,@UnitSaleId,@UnitStockId,");
                sb.Append("@ProductStockConvert,@UnitConvertId,@ProductStockReorder,@ProductPackQuantity,@ProductPackWeight,@ProductOrderId,@UnitPackId)");

                string sqlAdd;
                sqlAdd = sb.ToString();

                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();

                // ต่อ String รหัสสินค้า

                String strProductParentId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text;
                String strProductId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text;
                strProductId += "-";
                strProductId += txtBarcode5.Text;

                com.Parameters.Add("@ProductId", SqlDbType.NVarChar).Value = strProductId;
                com.Parameters.Add("@ProductOrderId", SqlDbType.NVarChar).Value = txtNewBarcode3.Text.Trim();
                com.Parameters.Add("@ProductIdExternal", SqlDbType.NVarChar).Value = txtProductIdExternal.Text.Trim();
                com.Parameters.Add("@ProductIdExternal2", SqlDbType.NVarChar).Value = txtProductIdExternal2.Text.Trim();
                com.Parameters.Add("@ProductParentId", SqlDbType.NVarChar).Value = strProductParentId;
                com.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value = txtProductName.Text.Trim();
                com.Parameters.Add("@ProductNameEng", SqlDbType.NVarChar).Value = txtProductNameEng.Text.Trim();
                com.Parameters.Add("@ProductDescript", SqlDbType.NVarChar).Value = txtProductDescript.Text.ToString();
                com.Parameters.Add("@MainCateId", SqlDbType.NVarChar).Value = cboMainCate.SelectedValue.ToString();
                com.Parameters.Add("@SubCateId", SqlDbType.NVarChar).Value = cboSubCate.SelectedValue.ToString();
                com.Parameters.Add("@UnitChildId", SqlDbType.NVarChar).Value = cboUnitChild.SelectedValue.ToString();
                com.Parameters.Add("@UnitSaleId", SqlDbType.NVarChar).Value = cboUnitSale.SelectedValue.ToString();
                com.Parameters.Add("@UnitStockId", SqlDbType.NVarChar).Value = cboUnitStock.SelectedValue.ToString();
                com.Parameters.Add("@ProductStockConvert", SqlDbType.NVarChar).Value = txtProductConvert.Text.Trim();
                com.Parameters.Add("@UnitConvertId", SqlDbType.NVarChar).Value = cboUnitConvert.SelectedValue.ToString();
                com.Parameters.Add("@ProductStockReorder", SqlDbType.NVarChar).Value = txtProductReorder.Text.Trim();
                com.Parameters.Add("@ProductPackQuantity", SqlDbType.NVarChar).Value = txtQauntityPack.Text.Trim();
                com.Parameters.Add("@ProductPackWeight", SqlDbType.NVarChar).Value = txtQuantityWeight.Text.Trim();
                com.Parameters.Add("@UnitPackId", SqlDbType.NVarChar).Value = cboUnitPack.SelectedValue.ToString();

                // com.Parameters.Add("@ProductDateEntry", SqlDbType.NVarChar).Value = dateTime.ToLongDateString();
                /*
                if (ProductPhoto != "")
                {
                    com.Parameters.Add("@ProductPhoto", SqlDbType.Image).Value = CurrentImage;
                }
                */
                com.ExecuteNonQuery();
                tr.Commit();

                MessageBox.Show("เพิ่มหน่วยนับสินค้าใหม่ที่ " + DatabaseName + " เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataMain.frmProductMain frmProductMain = new KTCERP.DataMain.frmProductMain();
                Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show("เพิ่มไม่ได้ครับ \n เนื่องจาก " + ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tr.Rollback();
            }
        }
コード例 #3
0
ファイル: frmProductEdit.cs プロジェクト: itktc/projectktc-v2
        //------ Delete
        public void deleteproduct(string NameShop, string OldProductId)
        {
            // ต่อ String รหัสสินค้า

            String strProductParentId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text;
            String strProductId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text;
            strProductId += "-";
            strProductId += txtBarcode5.Text;

            // string ProductId;
            string cksql = "SELECT ProductId FROM PRODUCT WHERE ProductId ='" + strProductId + "'";

            com = new SqlCommand();
            dt = new DataTable();

            com.CommandText = cksql;
            com.CommandType = CommandType.Text;
            com.Connection = Conn;
            dr = com.ExecuteReader();
            if (dr.HasRows)
            {
                dt.Load(dr);
                int TotalRecord = dt.Rows.Count;
                //  MessageBox.Show(TotalRecord.ToString());
                if (TotalRecord == 1)
                {
                    actionck = 1;
                }
                else
                {
                    actionck = 2;
                }
            }

            dr.Close();

            if (actionck == 1)
            {
                tr = Conn.BeginTransaction();

                try
                {
                    sb = new StringBuilder();
                    sb.Remove(0, sb.Length);

                    //sb.Append("UPDATE PRODUCT");
                    //sb.Append(" SET  ProductId=@ProductId");
                    //sb.Append(",ProductIdExternal=@ProductIdExternal");
                    //sb.Append(",ProductParentId=@ProductParentId");
                    //sb.Append(",ProductName=@ProductName");
                    //sb.Append(",ProductNameEng=@ProductNameEng");
                    //sb.Append(",MainCateId=@MainCateId");
                    //sb.Append(",SubCateId=@SubCateId");
                    //sb.Append(",UnitChildId=@UnitChildId");
                    //sb.Append(",UnitSaleId=@UnitSaleId");
                    //sb.Append(",UnitPackId=@UnitPackId");
                    //sb.Append(",UnitStockId=@UnitStockId");
                    //sb.Append(",ProductStockConvert=@ProductStockConvert");
                    //sb.Append(",UnitConvertId=@UnitConvertId");
                    //sb.Append(",ProductDateEntry=@ProductDateEntry");
                    //sb.Append(" WHERE (ProductId=@OldProductId)");

                    sb.Append(" DELETE FROM  PRODUCT  ");
                    sb.Append(" WHERE (ProductId=@OldProductId)");

                    string sqlAdd;
                    sqlAdd = sb.ToString();

                    com.CommandText = sqlAdd;
                    com.CommandType = CommandType.Text;
                    com.Connection = Conn;
                    com.Transaction = tr;
                    com.Parameters.Clear();

                    //com.Parameters.Add("@ProductId", SqlDbType.NVarChar).Value = strProductId;
                    com.Parameters.Add("@OldProductId", SqlDbType.NVarChar).Value = OldProductId;
                    //com.Parameters.Add("@ProductOrderId", SqlDbType.NVarChar).Value = txtNewBarcode3.Text.Trim();
                    //com.Parameters.Add("@ProductIdExternal", SqlDbType.NVarChar).Value = txtProductIdExternal.Text.Trim();
                    //com.Parameters.Add("@ProductParentId", SqlDbType.NVarChar).Value = strProductParentId;
                    //com.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value = txtProductName.Text.Trim();
                    //com.Parameters.Add("@ProductNameEng", SqlDbType.NVarChar).Value = txtProductNameEng.Text.Trim();
                    //com.Parameters.Add("@MainCateId", SqlDbType.NVarChar).Value = cboMainCate.SelectedValue.ToString();
                    //com.Parameters.Add("@SubCateId", SqlDbType.NVarChar).Value = cboSubCate.SelectedValue.ToString();
                    //com.Parameters.Add("@UnitChildId", SqlDbType.NVarChar).Value = cboUnitChild.SelectedValue.ToString();
                    //com.Parameters.Add("@UnitSaleId", SqlDbType.NVarChar).Value = cboUnitSale.SelectedValue.ToString();
                    //com.Parameters.Add("@UnitPackId", SqlDbType.NVarChar).Value = cboUnitPack.SelectedValue.ToString();
                    //com.Parameters.Add("@UnitStockId", SqlDbType.NVarChar).Value = cboUnitStock.SelectedValue.ToString();
                    //com.Parameters.Add("@ProductStockConvert", SqlDbType.NVarChar).Value = txtProductConvet.Text.Trim();
                    //com.Parameters.Add("@UnitConvertId", SqlDbType.NVarChar).Value = cboUnitConvert.SelectedValue.ToString();
                    //com.Parameters.Add("@ProductStockReorder", SqlDbType.NVarChar).Value = txtProductReorder.Text.Trim();
                    //com.Parameters.Add("@ProductPackQuantity", SqlDbType.NVarChar).Value = txtQauntityPack.Text.Trim();
                    //com.Parameters.Add("@ProductPackWeight", SqlDbType.NVarChar).Value = txtQuantityWeight.Text.Trim();
                    //com.Parameters.Add("@ProductDateEntry", SqlDbType.DateTime).Value = DateTime.Now;
                    com.ExecuteNonQuery();
                    tr.Commit();

                    DataMain.frmProductMain frmProductMain = new KTCERP.DataMain.frmProductMain();

                    MessageBox.Show("ลบรายการสินค้า เรียบร้อยแล้ว !!! " + NameShop.ToString(), "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
                catch (Exception ex)
                {

                    MessageBox.Show(NameShop.ToString() + " ลบรายการสินค้านี้ไม่ได้ครับ \n เนื่องจาก " + ex.Message + "\n", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tr.Rollback();
                }

            }
            else if (actionck == 2)
            {

                MessageBox.Show("ไม่พบ : " + NameShop.ToString());
            }
        }
コード例 #4
0
        public void InsertProductPhoto(string DatabaseName)
        {
            tr = Conn.BeginTransaction();
            try
            {

                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append("INSERT INTO PRODUCT_PHOTO (PhotoId,Patch,PhotoName,ProductId)");
                sb.Append("VALUES (1," + "strPatch" + "," + textBox1.Text + "," + strProductId + ");");
                string sqlAdd;
                sqlAdd = sb.ToString();
                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();
                com.ExecuteNonQuery();
                tr.Commit();
                MessageBox.Show("เพิ่มข้อมูลที่ " + DatabaseName + " เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataMain.frmProductMain frmProductMain = new KTCERP.DataMain.frmProductMain();

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ล้มเหลว \n เนื่องจาก " + ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tr.Rollback();
            }
        }
コード例 #5
0
ファイル: frmProductAdd.cs プロジェクト: itktc/projectktc-v2
        public void insertproduct(string DatabaseName)
        {
            tr = Conn.BeginTransaction();
            try
            {
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append("INSERT INTO PRODUCT (ProductId,ProductIdExternal,ProductIdExternal2,ProductParentId,ProductName,ProductNameEng,");
                sb.Append("ProductDescript,MainCateId,SubCateId,UnitChildId,UnitSaleId,UnitPackId,UnitStockId,");
                sb.Append("ProductStockConvert,UnitConvertId,ProductStockReorder,ProductPackQuantity,ProductPackWeight,ProductOrderId,ProductDateEntry)");
                sb.Append(" VALUES (@ProductId,@ProductIdExternal,@ProductIdExternal2,@ProductParentId,@ProductName,@ProductNameEng,");
                sb.Append("@ProductDescript,@MainCateId,@SubCateId,@UnitChildId,@UnitSaleId,@UnitPackId,@UnitStockId,");
                sb.Append("@ProductStockConvert,@UnitConvertId,@ProductStockReorder,@ProductPackQuantity,@ProductPackWeight,@ProductOrderId,@ProductDateEntry)");

                // ต่อ String รหัสสินค้า
                string sqlAdd;
                sqlAdd = sb.ToString();

                com.CommandText = sqlAdd;
                com.CommandType = CommandType.Text;
                com.Connection = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();

                String strProductParentId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text;
                strProductId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text;
                strProductId += "-";
                strProductId += txtBarcode5.Text;

                com.Parameters.Add("@ProductId", SqlDbType.NVarChar).Value = strProductId;
                com.Parameters.Add("@ProductOrderId", SqlDbType.NVarChar).Value = txtNewBarcode3.Text.Trim();
                com.Parameters.Add("@ProductIdExternal", SqlDbType.NVarChar).Value = txtProductIdExternal.Text.Trim();
                com.Parameters.Add("@ProductIdExternal2", SqlDbType.NVarChar).Value = txtProductIdExternal2.Text.Trim();
                com.Parameters.Add("@ProductParentId", SqlDbType.NVarChar).Value = strProductParentId;
                com.Parameters.Add("@ProductName", SqlDbType.NVarChar).Value = txtProductName.Text.Trim();
                com.Parameters.Add("@ProductNameEng", SqlDbType.NVarChar).Value = txtProductNameEng.Text.Trim();
                com.Parameters.Add("@ProductDescript", SqlDbType.NVarChar).Value = txtProductDescript.Text.ToString();
                com.Parameters.Add("@MainCateId", SqlDbType.NVarChar).Value = cboMainCate.SelectedValue.ToString();
                com.Parameters.Add("@SubCateId", SqlDbType.NVarChar).Value = cboSubCate.SelectedValue.ToString();
                com.Parameters.Add("@UnitChildId", SqlDbType.NVarChar).Value = cboUnitChild.SelectedValue.ToString();
                com.Parameters.Add("@UnitSaleId", SqlDbType.NVarChar).Value = cboUnitSale.SelectedValue.ToString();
                com.Parameters.Add("@UnitPackId", SqlDbType.NVarChar).Value = cboUnitPack.SelectedValue.ToString();
                com.Parameters.Add("@UnitStockId", SqlDbType.NVarChar).Value = cboUnitStock.SelectedValue.ToString();
                com.Parameters.Add("@ProductStockConvert", SqlDbType.NVarChar).Value = txtProductConvert.Text.Trim();
                com.Parameters.Add("@UnitConvertId", SqlDbType.NVarChar).Value = cboUnitConvert.SelectedValue.ToString();
                com.Parameters.Add("@ProductStockReorder", SqlDbType.NVarChar).Value = txtProductReorder.Text.Trim();
                com.Parameters.Add("@ProductPackQuantity", SqlDbType.NVarChar).Value = txtQauntityPack.Text.Trim();
                com.Parameters.Add("@ProductPackWeight", SqlDbType.NVarChar).Value = txtQuantityWeight.Text.Trim();
                com.Parameters.Add("@ProductDateEntry", SqlDbType.DateTime).Value = DateTime.Now;

                com.ExecuteNonQuery();

                tr.Commit();
                DialogResult dlg = MessageBox.Show("ต้องการพิมพ์รายงานหรือไม่ !!!", "ผลการทำงาน", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (dlg == DialogResult.OK)
                {
                    DataMain.rptProductAdd rpt = new rptProductAdd();
                    rpt.StartPosition = FormStartPosition.CenterScreen;   // กำหนด frm ย่อย ให้อยู่ตรงกลาง
                    rpt.setProductId = strProductId;
                    rpt.ShowDialog();

                }
                MessageBox.Show("เพิ่มสินค้าใหม่ที่ " + DatabaseName + " เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DataMain.frmProductMain frmProductMain = new KTCERP.DataMain.frmProductMain();

                Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show("เพิ่มไม่ได้ครับ \n เนื่องจาก " + ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tr.Rollback();
            }
        }