Exemplo n.º 1
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            if (txtJnsTrans.Text.Substring(0, 1) == "K")
            {
                uraian = "PJK (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            }

            if (txtJnsTrans.Text.Substring(0, 1) == "T")
            {
                uraian = "PJT (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            }

            NamaToko_ = Tools.isNull(dtNota.Rows[0]["NamaToko"], "").ToString().Trim();
            Sales_    = Tools.isNull(dtNota.Rows[0]["KodeSales"], "").ToString().Trim().Substring(7, 3);

            /***************************************************************
            * Code di bawah ini sudah tidak di pakai karena tidak ada lagi
            * karena PJ3 tidak lagi ada jenis transaksi berinitial "T"
            ***************************************************************/
            //else
            //{
            //    if (txtJnsTrans.Text.Substring(0, 1) == "T")
            //    {
            //        uraian = "PJT (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            //        hariKredit = 3;
            //    }
            //    else
            //        uraian = "PENJUALAN (" + Tools.isNull(dtNota.Rows[0]["NamaSales"], "").ToString() + ")";
            //}

            /* Isi TglTerima */
            try
            {
                GlobalVar.LastClosingDate = (DateTime)txtTglTerima.DateValue;
                if (txtTglTerima.DateValue <= GlobalVar.LastClosingDate)
                {
                    KotakPesan.Information(String.Format(Messages.Error.AlreadyClosingPJT, GlobalVar.LastClosingDate));
                    return;
                }
                if (MessageBox.Show("Tgl Jatuh Tempo Nota ini: " + HitungTglJatuhTempo().ToString("dd-MMM-yyyy") + ", data akan disimpan?", "KONFIRMASI", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    IsiTglTerima();
                }
                else
                {
                    this.DialogResult = DialogResult.No;
                    return;
                }

                /* Proses link ke piutang */
                string cCab1 = Tools.isNull(dtNota.Rows[0]["Cabang1"], "").ToString().Trim();
                string cCab2 = Tools.isNull(dtNota.Rows[0]["Cabang2"], "").ToString().Trim();

                if (cCab1 == GlobalVar.CabangID && cCab2 == GlobalVar.CabangID)
                {
                    LinkKePiutang();
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (System.Exception ex)
            {
                Error.LogError(ex);
            }
        }
Exemplo n.º 2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (dataSudahAda())
            {
                KotakPesan.Warning("Data Sudah Ada di database");
                txtNama.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtNama.Text))
            {
                KotakPesan.Warning("Anda belum mengisi data Nama");
                txtNama.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtLokasi.Text))
            {
                KotakPesan.Warning("Anda belum mengisi data Lokasi");
                txtLokasi.Focus();
                return;
            }
            try
            {
                switch (formMode)
                {
                case enumFormMode.NEW:

                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        db.Open();
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("[usp_BankKota_INSERT]"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[0].Parameters.Add(new Parameter("@Nama", SqlDbType.VarChar, txtNama.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Lokasi", SqlDbType.VarChar, txtLokasi.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusAktif", SqlDbType.Bit, cbaktif.Checked));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserName));
                        dt = db.Commands[0].ExecuteDataTable();
                        db.Close();
                        db.Dispose();
                        KotakPesan.Information("Insert Berhasil");
                    }
                    break;

                case enumFormMode.UPDATE:
                    using (Database db = new Database(GlobalVar.DBFinance))
                    {
                        db.Open();
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("[usp_BankKota_UPDATE]"));
                        db.Commands[0].Parameters.Add(new Parameter("@RowID", SqlDbType.UniqueIdentifier, RowID));
                        db.Commands[0].Parameters.Add(new Parameter("@Nama", SqlDbType.VarChar, txtNama.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Lokasi", SqlDbType.VarChar, txtLokasi.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@StatusAktif", SqlDbType.Bit, cbaktif.Checked));
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserName));
                        dt = db.Commands[0].ExecuteDataTable();
                        db.Close();
                        db.Dispose();
                        KotakPesan.Information("Update Berhasil");
                    }
                    break;
                }
                this.DialogResult = DialogResult.OK;
                frmBankKotaBrowse frmcaller = (frmBankKotaBrowse)this.Caller;
                frmcaller.RefreshData();
                this.Close();
                frmcaller.Show();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }