private void HapusTSB_Click(object sender, EventArgs e) { if (dtGrid.RowCount < 0) { if (new grnCRUD().deleteData(txtGRNNO.Text)) { MessageBox.Show(" Items Receive telah di hapus "); } } else //delete detail { gindetail k = new gindetail(); dtGrid.EndEdit(); for (int i = 0; i < dtGrid.Rows.Count - 1; i++) { k.GRNNO = txtGRNNO.Text; k.ID = Convert.ToInt32(dtGrid.Rows[i].Cells["hID1"].Value); if ((Convert.ToInt32(dtGrid.Rows[i].Cells["hDel"].Value) == 1) && (dtGrid.Rows[i].Cells["hID1"].Value != null)) { if (new gindetailCRUD().deleteData(k.GRNNO, k.ID)) { dtGrid.Rows.RemoveAt(i); } else if ((dtGrid.Rows[i].Cells["hID1"].Value.ToString() == null)) { dtGrid.Rows.RemoveAt(i); } else { MessageBox.Show("gagal delete"); } } } }// end bro }
private void UbahTSB_Click(object sender, EventArgs e) { //simpan header gin k = new gin(); //Generate gen = new Generate(); // txtGRNNO.Text = gen.genPIN(); //k.PONO = txtPONO.Text; k.GINNO = txtGRNNO.Text; k.DATE = dateCreated.Value; DataRow selectedDIV = ((DataRowView)cbDIV.SelectedItem).Row; k.GDIV = selectedDIV["DIVID"].ToString(); k.APPROVE = 0; k.APPROVEBY = ""; k.CLOSE = 0; // k.COLORID = ""; k.CUSTVENDCODE = txtCustomerID.Text; k.DOCREGNO = ""; k.OFFICER = GlobalVariables.GUserID; //k.RECEIVEFROM = 3;// from po process //k.REMARKS=txte txtRefer.Text; k.REMARKS = txtRemarks.Text; k.STOREID = cbStore.Text; k.TYPE = cbJENIS.Text; if ((txtGRNNO.Text == "") || (txtPONO.Text == "")) { MessageBox.Show("Isian Belum lengkap untuk PONO"); } else if (new ginCRUD().updateData(k)) { gindetail d = new gindetail(); dtGrid.EndEdit(); string GINNO1; int ID1; for (int i = 0; i < dtGrid.Rows.Count - 1; i++) { //d.PONO = txtPONO.Text; //d.GINNO = txtGRNNO.Text; GINNO1 = Convert.ToString(dtGrid.Rows[i].Cells["hItemsID"].Value); ID1 = Convert.ToInt32(dtGrid.Rows[i].Cells["hItemsID"].Value); d.GRNNO = Convert.ToString(dtGrid.Rows[i].Cells["hItemsID"].Value); d.GINNO = Convert.ToString(dtGrid.Rows[i].Cells["hItemsID"].Value); d.ID = Convert.ToInt32(dtGrid.Rows[i].Cells["hItemsID"].Value); d.ITEMSID = dtGrid.Rows[i].Cells["hItemsID"].Value == null ? null : dtGrid.Rows[i].Cells["hItemsID"].Value.ToString(); d.DESCRIPTION = dtGrid.Rows[i].Cells["hDescription"].Value == null ? null : dtGrid.Rows[i].Cells["hDescription"].Value.ToString().ToString(); d.QUANTITY = Convert.ToDecimal(dtGrid.Rows[i].Cells["hQuantity"].Value); d.UOM = dtGrid.Rows[i].Cells["hUOM"].Value == null ? null : dtGrid.Rows[i].Cells["hUOM"].Value.ToString(); d.COLORID = ""; d.GRADE = ""; d.JENIS = cbJENIS.Text; d.SIZEID = ""; d.STYLEID = dtGrid.Rows[i].Cells["hStyleID"].Value == null ? null : dtGrid.Rows[i].Cells["hStyleID"].Value.ToString(); d.STYLEIDTO = dtGrid.Rows[i].Cells["hStyleID"].Value == null ? null : dtGrid.Rows[i].Cells["hStyleID"].Value.ToString(); if (dtGrid.Rows[i].HeaderCell.Value.ToString() != "#") { if (new gindetailCRUD().updateData(d, GINNO1, ID1)) { dtGrid.Rows[i].HeaderCell.Value = "V"; } else { } } } MessageBox.Show("Data berhasil di tambahkan"); SimpanTSB.Enabled = false; UbahTSB.Enabled = true; dtGrid.Enabled = true; // Binding(); } else { MessageBox.Show("Data gagal ditambahkan"); } }