private void UbahTSB_Click(object sender, EventArgs e) { joborder K = new joborder(); K.ORDERNO = txtCostingNo.Text; DataRow selectedDataRow = ((DataRowView)cbTypeID.SelectedItem).Row; K.TYPEID = selectedDataRow["TYPEID"].ToString(); DataRow selectedDIV = ((DataRowView)cbDIV.SelectedItem).Row; K.GDIV = selectedDIV["DIVID"].ToString(); K.QUANTITY = Convert.ToInt32(txtQty.Text); K.CATEGORYID = txtCategoryID.Text; K.CUSTVENDCODE = txtCustomerID.Text; K.ITEMSID = txtStyleID.Text; K.DATE = dateCreated.Value; //K.OFFICER = ""; K.POCUSTOMER = txtPOCustomer.Text; K.REMARKS = txtRemarks.Text; K.WASH = txtWash.Text; if (new joborderCRUD().updateData(K)) { joborderdetail k = new joborderdetail(); dtGrid.EndEdit(); for (int i = 0; i < dtGrid.Rows.Count - 1; i++) { k.ORDERNO = txtCostingNo.Text; k.POCUSTOMER = Convert.ToString(dtGrid.Rows[i].Cells["hPOCustomer"].Value); k.COLORID = Convert.ToString(dtGrid.Rows[i].Cells["hColorID"].Value); k.SIZEID = Convert.ToString(dtGrid.Rows[i].Cells["hSizeID"].Value); k.NOURUT = Convert.ToInt16(dtGrid.Rows[i].Cells["hNoUrut"].Value); //dtGrid.Rows[i].Cells["hUOMPurchase"].Value == null ? null : dtGrid.Rows[i].Cells["hUOMPurchase"].Value.ToString(); //if (!dtGrid.Rows[i].Cells["hDelivery"].Value..HasValue) k.DELIVERY = Convert.ToDateTime(dtGrid.Rows[i].Cells["hDelivery"].Value, new CultureInfo("id")); k.QUANTITY = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hQuantity"].Value); k.CUTTINGQTY = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hCuttingQty"].Value); k.ALLOWANCE = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hAllowance"].Value); k.DESTINATION = Convert.ToString(dtGrid.Rows[i].Cells["hDestination"].Value); if (dtGrid.Rows[i].HeaderCell.Value.ToString() == "#") { //insert if (new joborderdetailCRUD().insertData(k)) { dtGrid.Rows[i].HeaderCell.Value = "V"; } } else {// update if (new joborderdetailCRUD().updateData(k)) { dtGrid.Rows[i].HeaderCell.Value = "V"; } else { MessageBox.Show("gagal"); } } } MessageBox.Show("Update Sukses"); load_data(txtCostingNo.Text); } else { MessageBox.Show("Data gagal update"); } }
private void SimpanTSB_Click(object sender, EventArgs e) { Generate gen = new Generate(); txtCostingNo.Text = gen.genJO(); joborder K = new joborder(); K.ORDERNO = gen.genJO(); DataRow selectedDataRow = ((DataRowView)cbTypeID.SelectedItem).Row; K.TYPEID = selectedDataRow["TYPEID"].ToString(); DataRow selectedDIV = ((DataRowView)cbDIV.SelectedItem).Row; K.GDIV = selectedDIV["DIVID"].ToString(); K.QUANTITY = Convert.ToInt32(txtQty.Text); K.CATEGORYID = txtCategoryID.Text; K.CUSTVENDCODE = txtCustomerID.Text; K.ITEMSID = txtStyleID.Text; K.DATE = dateCreated.Value; K.OFFICER = GlobalVariables.GUserID; K.POCUSTOMER = txtPOCustomer.Text; K.REMARKS = txtRemarks.Text; K.WASH = txtWash.Text; if ((txtCategoryID.Text == "") || (txtCustomerID.Text == "")) { MessageBox.Show("Isian Belum lengkap untuk category, style atau customer"); } else if (new joborderCRUD().insertData(K)) { joborderdetail k = new joborderdetail(); dtGrid.EndEdit(); for (int i = 0; i < dtGrid.Rows.Count - 1; i++) { k.ORDERNO = txtCostingNo.Text; k.POCUSTOMER = Convert.ToString(dtGrid.Rows[i].Cells["hPOCustomer"].Value); k.COLORID = Convert.ToString(dtGrid.Rows[i].Cells["hColorID"].Value); k.SIZEID = Convert.ToString(dtGrid.Rows[i].Cells["hSizeID"].Value); k.NOURUT = Convert.ToInt16(dtGrid.Rows[i].Cells["hNoUrut"].Value); //dtGrid.Rows[i].Cells["hUOMPurchase"].Value == null ? null : dtGrid.Rows[i].Cells["hUOMPurchase"].Value.ToString(); //if (!dtGrid.Rows[i].Cells["hDelivery"].Value..HasValue) k.DELIVERY = DateTime.Parse(dtGrid.Rows[i].Cells["hDelivery"].Value.ToString(), null); k.QUANTITY = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hQuantity"].Value); k.CUTTINGQTY = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hCuttingQty"].Value); k.ALLOWANCE = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hAllowance"].Value); k.DESTINATION = Convert.ToString(dtGrid.Rows[i].Cells["hDestination"].Value); if (dtGrid.Rows[i].HeaderCell.Value.ToString() == "#") { //insert if (new joborderdetailCRUD().insertData(k)) { dtGrid.Rows[i].HeaderCell.Value = "V"; } } else {// update if (new joborderdetailCRUD().updateData(k)) { dtGrid.Rows[i].HeaderCell.Value = "V"; } else { MessageBox.Show("gagal"); } } } MessageBox.Show("Data berhasil di tambahkan"); load_data(txtCostingNo.Text); SimpanTSB.Enabled = false; UbahTSB.Enabled = true; dtGrid.Enabled = true; } else { MessageBox.Show("Data gagal ditambahkan"); } }