Пример #1
0
 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
     {
         grndetail k = new grndetail();
         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 grndetailCRUD().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");
                 }
             }
         }
     }
 }
Пример #2
0
        private void UbahTSB_Click(object sender, EventArgs e)
        {
            //simpan header
            grn k = new grn();

            k.PONO  = txtJONO.Text;
            k.GRNNO = 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      = "";
            k.RECEIVEFROM  = 1;// from PO
            k.REFFNO       = txtRefer.Text;
            k.REMARKS      = txtRemarks.Text;
            k.STOREID      = cbStore.Text;
            k.JENIS        = cbJENIS.Text;

            if ((txtGRNNO.Text == ""))
            {
                MessageBox.Show("Isian Belum lengkap untuk PONO");
            }
            else if (new grnCRUD().updateData(k))
            {
                string GRNNO1;
                int    ID1;

                grndetail d = new grndetail();
                dtGrid.EndEdit();
                for (int i = 0; i < dtGrid.Rows.Count - 1; i++)
                {
                    //key
                    GRNNO1 = txtGRNNO.Text;
                    ID1    = Convert.ToInt32(dtGrid.Rows[i].Cells["hID1"].Value); //i+1;//Convert.ToInt32(dtGrid.Rows[i].Cells["hCostingID"].Value);
                    //endkey
                    d.PONO        = txtJONO.Text;
                    d.GRNNO       = txtGRNNO.Text;
                    d.ID          = Convert.ToInt32(dtGrid.Rows[i].Cells["hID"].Value); //i+1;//Convert.ToInt32(dtGrid.Rows[i].Cells["hCostingID"].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.CONVER      = Convert.ToDecimal(dtGrid.Rows[i].Cells["hConvert"].Value);
                    d.QTYPURCHASE = Convert.ToDecimal(dtGrid.Rows[i].Cells["hQtyPurchase"].Value);
                    d.UOMPURCHASE = dtGrid.Rows[i].Cells["hUOMPurchase"].Value == null ? null : dtGrid.Rows[i].Cells["hUOMPurchase"].Value.ToString();
                    d.COLORID     = "";
                    d.GRADE       = "PRODUCT";
                    d.JENIS       = "";
                    d.SIZEID      = "";
                    d.STYLEID     = "";
                    if (dtGrid.Rows[i].HeaderCell.Value.ToString() == "#")
                    {
                        // ID1 = GlobalVariables.GID;
                        if (new grndetailCRUD().insertData(d))
                        {
                            dtGrid.Rows[i].HeaderCell.Value = "V";
                            ID1 = GlobalVariables.GID + 1;
                        }
                        else
                        {
                            if (new grndetailCRUD().updateData(d, GRNNO1, ID1))
                            {
                                // MessageBox.Show("Data berhasil di tambahkan");
                                // Binding();
                                dtGrid.Rows[i].HeaderCell.Value = "V";
                            }
                            else
                            {
                                MessageBox.Show("gagal");
                            }
                        }
                    }
                }

                MessageBox.Show("Data berhasil di tambahkan");
                SimpanTSB.Enabled = false;
                // Binding();
            }
            else
            {
                MessageBox.Show("Data gagal ditambahkan");
            }

            //simpang detail
        }