private void AddPProduct_Click(object sender, EventArgs e) { DataMain.frmProduction frm = new KTCERP.DataMain.frmProduction(); frm.MdiParent = this; frm.StartPosition = FormStartPosition.CenterScreen; frm.Show(); }
private void InsertProduction() { tr = Conn.BeginTransaction(); try { sb = new StringBuilder(); sb.Remove(0, sb.Length); sb.Append("insert into ProductionProduct(PProductId,PProductTypeId,PProductSubId,PProductName)"); sb.Append("values(@PProductId,@PProductTypeId,@PProductSubId,@PProductName)"); //sb.Append("INSERT INTO PRODUCT (ProductId,ProductIdExternal,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,@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 strPProductId = lblMainId.Text + lblSubId.Text; //string strPProductName = txtPProductType.Text+" "+txtNum.Text+" "+txtSize.Text+cboUnitSize.SelectedItem.ToString().Trim(); //strPProductName += "(" + txtDeep.Text + cboUnitDeep.SelectedItem.ToString().Trim() + ")"; //strPProductName += " " + txtColor.Text +" " + txtColorTung.Text +" "+ txtKind.Text; //strPProductName = txtPProductType.Text + " " + txtNum.Text + " " + txtSize.Text +" "+ cboUnitSize.SelectedItem.ToString().Trim() +" "+ "x"+" "; //strPProductName += txtDeep.Text +" "+ cboUnitDeep.SelectedItem.ToString().Trim() +" "+ "x" +" "+txtSizeNet.Text +" "+ cboUnitSizeNet.SelectedItem.ToString().Trim()+" "; //strPProductName += txtColor.Text + " " + txtColorTung.Text + " " + txtKind.Text + " " + txtBrand.Text; //String strProductParentId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text; //strProductId = txtNewBarcode1.Text + txtNewBarcode2.Text + txtNewBarcode3.Text; //strProductId += "-"; //strProductId += txtBarcode5.Text; com.Parameters.Add("@PProductId", SqlDbType.NVarChar).Value = strPProductId; com.Parameters.Add("@PProductTypeId", SqlDbType.Int).Value = Convert.ToInt16(lblMainId.Text.Trim()); com.Parameters.Add("@PProductSubId", SqlDbType.Int).Value = Convert.ToInt16(lblSubId.Text.Trim()); com.Parameters.Add("@PProductName", SqlDbType.NVarChar).Value = strPProductName; //MessageBox.Show(strPProductName); 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("เพิ่มสินค้าใหม่ เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); DataMain.frmProduction frm = new KTCERP.DataMain.frmProduction(); Close(); } catch (Exception ex) { MessageBox.Show("เพิ่มไม่ได้ครับ \n เนื่องจาก " + ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); tr.Rollback(); } }
private void EditPProduct() { strPProductName = strPProductName = txtPProductType.Text + " " + txtNum.Text + " " + txtSize.Text + " " + cboUnitSize.SelectedItem.ToString().Trim() + " " + "x" + " "; strPProductName += txtDeep.Text + " " + cboUnitDeep.SelectedItem.ToString().Trim() + " " + "x" + " " + txtSizeNet.Text + " " + cboUnitSizeNet.SelectedItem.ToString().Trim() + " "; strPProductName += txtColor.Text + " " + txtColorTung.Text + " " + txtKind.Text + " " + txtBrand.Text; tr = Conn.BeginTransaction(); try { sb = new StringBuilder(); sb.Remove(0,sb.Length); sb.Append("update ProductionProduct set PProductName = @PProductName "); sb.Append("where PProductId = @PProductId"); string sqlEditPProduct; sqlEditPProduct = sb.ToString(); com.CommandText = sqlEditPProduct; com.CommandType = CommandType.Text; com.Connection = Conn; com.Transaction = tr; com.Parameters.Clear(); com.Parameters.Add("@PProductName", SqlDbType.NVarChar).Value = strPProductName; com.Parameters.Add("@PProductId", SqlDbType.NVarChar).Value = txtPProductId.Text.Trim(); com.ExecuteNonQuery(); tr.Commit(); MessageBox.Show("แก้ไข เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); DataMain.frmProduction frm = new KTCERP.DataMain.frmProduction(); Close(); } catch(Exception ex) { MessageBox.Show("เพิ่มไม่ได้ครับ \n เนื่องจาก " + ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information); tr.Rollback(); } }