Пример #1
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_NoBPKB.Text == "")
                {
                    MessageBox.Show("No BPKB belum diisi");
                    return;
                }
                using (Database db = new Database(GlobalVar.DBFinanceOto))
                {
                    db.Commands.Add(db.CreateCommand("usp_MasterSTNK_UpdateBPKP"));
                    db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, MasterSTNKRowID));
                    db.Commands[0].Parameters.Add(new Parameter("@TglTerimaBPKB", SqlDbType.DateTime, txt_TglTerimaBPKB.DateValue));
                    db.Commands[0].Parameters.Add(new Parameter("@NoBPKB", SqlDbType.VarChar, txt_NoBPKB.Text));
                    db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                    db.Commands[0].ExecuteNonQuery();
                }

                MessageBox.Show("Data berhasil diproses");
                if (this.Caller is frmMasterSTNK)
                {
                    frmMasterSTNK frmCaller = (frmMasterSTNK)this.Caller;
                    frmCaller.RefreshData(MasterSTNKRowID);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
Пример #2
0
        private void cmdSAVE_Click(object sender, EventArgs e)
        {
            Database db = new Database(GlobalVar.DBFinanceOto);

            try
            {
                if (!cekSave())
                {
                    return;
                }

                //DataTable dt_cek = new DataTable();
                //using (Database dbCek = new Database(GlobalVar.DBFinanceOto))
                //{
                //    dbCek.Commands.Add(db.CreateCommand("usp_MasterSTNK_CekKTP"));
                //    dbCek.Commands[0].Parameters.Add(new Parameter("@NoKTP", SqlDbType.VarChar, txt_NoKTP.Text));
                //    dt_cek = dbCek.Commands[0].ExecuteDataTable();
                //}

                //if (dt_cek.Rows.Count > 0)
                //{
                //    String stnk = "";
                //    String bpkb = "";

                //    foreach (DataRow dr in dt_cek.Rows)
                //    {
                //        if (dr["NoSTNK"].ToString() != "")
                //        {
                //            stnk += dr["NoSTNK"].ToString() + ", ";
                //        }
                //        if (dr["NoBPKB"].ToString() != "")
                //        {
                //            bpkb += dr["NoBPKB"].ToString() + ", ";
                //        }
                //    }

                //    DialogResult dialogResult = MessageBox.Show("Data pengambil pernah mengambil STNK : "+ stnk+" dan BPKB : "+bpkb+" \n Apakah anda ingin melanjutkan proses ini ?", "Warning", MessageBoxButtons.YesNo);
                //    if (dialogResult == DialogResult.No)
                //    {
                //        return;
                //    }
                //}

                int counterdb = 0;

                if (GlobalVar.Aktif_IMG == "1" && GV_Attachment.Rows.Count == 0)
                {
                    MessageBox.Show("Data tidak memiliki file attachment, silahkan pilih file yang akan di upload terlebih dahulu.");
                    return;
                }

                if (GlobalVar.Aktif_IMG == "0")
                {
                    String dirPath;
                    dirPath = GlobalVar.MasterSTNK_AttachPath + "\\";
                    if (!Directory.Exists(dirPath))
                    {
                        Directory.CreateDirectory(dirPath);
                    }

                    if (GV_Attachment.Rows.Count > 0)
                    {
                        int    rowGV = 0;
                        string NamaFileSave;

                        for (rowGV = 0; rowGV < GV_Attachment.Rows.Count; rowGV++)
                        {
                            if (_action == "ambilBPKB")
                            {
                                NamaFileSave = "BPKB_" + txt_NamaSTNK.Text + "_" + GlobalVar.GetServerDate.ToString("ddMMyyyyHHmmss") + Path.GetExtension(GV_Attachment.Rows[rowGV].Cells["FileName"].Value.ToString());
                            }
                            else
                            {
                                NamaFileSave = "STNK_" + txt_NamaSTNK.Text + "_" + GlobalVar.GetServerDate.ToString("ddMMyyyyHHmmss") + Path.GetExtension(GV_Attachment.Rows[rowGV].Cells["FileName"].Value.ToString());
                            }

                            insertAttachment(ref db, ref counterdb, GV_Attachment.Rows[rowGV].Cells["FilePath"].Value.ToString(), GV_Attachment.Rows[rowGV].Cells["FileName"].Value.ToString(),
                                             dirPath, new Guid(Tools.isNull(GV_Attachment.Rows[rowGV].Cells["RowID"].Value, Guid.Empty).ToString()), GV_Attachment.Rows[rowGV].Cells["Keterangan"].Value.ToString(), NamaFileSave);
                        }

                        //ftpmanagementfile.Upload(GV_Attachment.Rows[0].Cells["FilePath"].Value.ToString(), GV_Attachment.Rows[0].Cells["FileName"].Value.ToString());
                    }
                }

                if (_action == "ambilBPKB")
                {
                    db.Commands.Add(db.CreateCommand("usp_MasterSTNK_UpdateBPKP"));
                    db.Commands[counterdb].Parameters.Add(new Parameter("@TglPengambilanBPKB", SqlDbType.DateTime, txt_TglPengambilan.DateValue));
                    db.Commands[counterdb].Parameters.Add(new Parameter("@NamaPengambilBPKB", SqlDbType.VarChar, txt_NamaPengambil.Text));
                    db.Commands[counterdb].Parameters.Add(new Parameter("@AlamatPengambilBPKB", SqlDbType.VarChar, txt_AlamatPengambil.Text));
                }
                else
                {
                    db.Commands.Add(db.CreateCommand("usp_MasterSTNK_Update"));
                    db.Commands[counterdb].Parameters.Add(new Parameter("@TglPengambilan", SqlDbType.DateTime, txt_TglPengambilan.DateValue));
                    db.Commands[counterdb].Parameters.Add(new Parameter("@NamaPengambil", SqlDbType.VarChar, txt_NamaPengambil.Text));
                    db.Commands[counterdb].Parameters.Add(new Parameter("@AlamatPengambil", SqlDbType.VarChar, txt_AlamatPengambil.Text));
                }
                db.Commands[counterdb].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, MasterSTNKRowID));
                db.Commands[counterdb].Parameters.Add(new Parameter("@NoKTP", SqlDbType.VarChar, txt_NoKTP.Text));
                db.Commands[counterdb].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));

                counterdb++;
                db.BeginTransaction();
                int looper = 0;
                for (looper = 0; looper < counterdb; looper++)
                {
                    db.Commands[looper].ExecuteNonQuery();
                }
                db.CommitTransaction();
                MessageBox.Show("Data berhasil diproses");

                if (this.Caller is frmMasterSTNK)
                {
                    frmMasterSTNK frmCaller = (frmMasterSTNK)this.Caller;
                    frmCaller.RefreshData(MasterSTNKRowID);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                MessageBox.Show("Data gagal diproses !\n" + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Пример #3
0
 private void masterSTNKToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Penjualan.frmMasterSTNK ifrmChild = new Penjualan.frmMasterSTNK();
     CheckMdiChildren(ifrmChild);
 }