Exemplo n.º 1
0
        public static void cancelTrans()
        {
            int idx = idxH_Trans;

            //Check trans apakah sudah dibayar atau belum
            // Kalau sudah bayar tpi mau cancel harus cek kalau d transnya sudah ada yang kirim
            // atau belum, Kemudian kalau cancel h trans, harus cancel di semua dtrans
            //Jika sudah,  tidak boleh di cancel
            if (idx >= 0)
            {
                H_Trans_ItemModel hti = new H_Trans_ItemModel();
                DataRow           row = hti.Table.Select($"ID ='{list_htrans[idx].ID}'").FirstOrDefault();
                if (row["STATUS"].ToString() == "W")
                {
                    //Check kalau sudah ada yang S
                    D_Trans_ItemModel dti = new D_Trans_ItemModel();
                    bool valid            = true;
                    foreach (DataRow rowDTI in dti.Table.Select($"ID_H_TRANS_ITEM = '{row["ID"]}'"))
                    {
                        if (rowDTI["STATUS"].ToString() != "W")
                        {
                            valid = false;
                        }
                    }
                    if (valid)
                    {
                        //Cancel
                        row["STATUS"] = "C";
                        foreach (DataRow rowDTI in dti.Table.Select($"ID_H_TRANS_ITEM = '{row["ID"]}'"))
                        {
                            rowDTI["STATUS"] = "C";
                        }
                        dti.update();
                        hti.update();
                        initH_Trans();
                        loadD_Trans();
                        MessageBox.Show("Transaksi berhasil di cancel !");
                    }
                    else
                    {
                        MessageBox.Show("Tidak bisa dicancel !");
                    }
                }
                else
                {
                    MessageBox.Show("Gagal Cancel !");
                }
            }
        }
Exemplo n.º 2
0
 public static void terimaBarang()
 {
     if (idxItem >= 0)
     {
         int idx = idxItem;
         Detail_Trans_Item dti = list_dtrans[idx];
         //Check kalau DTRANS HARUS SUDAH SELESAI
         if (dti.status == "SHIPPING")
         {
             D_Trans_ItemModel dtim = new D_Trans_ItemModel();
             DataRow           row  = dtim.Table.Select($"ID = '{dti.id}'").FirstOrDefault();
             row["STATUS"] = "D";
             dtim.update();
             //Check if status D_Trans sudah D semua ato blm
             // Kalau D semua nanti penjual dpt duit
             bool valid = true;
             foreach (DataRow item in dtim.Table.Select($"ID_H_TRANS_ITEM = '{row["ID_H_TRANS_ITEM"]}'"))
             {
                 if (item["STATUS"].ToString() != "D")
                 {
                     valid = false;
                 }
             }
             if (valid)
             {
                 foreach (DataRow rowDTI in dtim.Table.Select($"ID_H_TRANS_ITEM = '{row["ID_H_TRANS_ITEM"]}'"))
                 {
                     ItemModel   im     = new ItemModel();
                     DataRow     item   = im.Table.Select($"ID = '{rowDTI["ID_ITEM"]}'").FirstOrDefault();
                     SellerModel sm     = new SellerModel();
                     DataRow     seller = sm.Table.Select($"ID = '{item["ID_SELLER"]}'").FirstOrDefault();;
                     int         saldo  = Convert.ToInt32(row["JUMLAH"]) * Convert.ToInt32(item["HARGA"]);
                     saldo          += Convert.ToInt32(seller["SALDO"]);
                     seller["SALDO"] = saldo;
                     sm.update();
                 }
             }
             loadD_Trans();
             loadItem();
         }
         else
         {
             // Selain Shipping
             MessageBox.Show("ERROR");
         }
     }
 }