Exemplo n.º 1
0
 private void frmPinMd5_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.Caller is Penjualan.TabelDO)
     {
         if (_bagian != PinId.Bagian.Harga)
         {
             Penjualan.TabelDO frmCaller = (Penjualan.TabelDO) this.Caller;
             frmCaller.RefreshDataDO();
             try
             {
                 frmCaller.FindHeader("RowID", _rowID.ToString());
             }
             catch { };
         }
         else
         {
             Penjualan.TabelDO frm = (Penjualan.TabelDO)Caller;
             frm.RefreshDataDetailDO();
         }
     }
     else if (this.Caller is Penjualan.frmNotaJualBrowser)
     {
         Penjualan.frmNotaJualBrowser frmCaller = (Penjualan.frmNotaJualBrowser) this.Caller;
         frmCaller.RefreshDataDO();
     }
     else if (this.Caller is Penjualan.frmNotaReturJualBrowse)
     {
         Penjualan.frmNotaReturJualBrowse frmCaller = (Penjualan.frmNotaReturJualBrowse) this.Caller;
         frmCaller.RefreshDataReturJual();
     }
     else if (this.Caller is Penjualan.frmNotaJualUpdate)
     {
         Penjualan.frmNotaJualUpdate frmCaller = (Penjualan.frmNotaJualUpdate) this.Caller;
         frmCaller.RefreshDataNota();
     }
     else if (this.Caller is Penjualan.frmPotonganNotaBrowse)
     {
         Penjualan.frmPotonganNotaBrowse frmCaller = (Penjualan.frmPotonganNotaBrowse) this.Caller;
         frmCaller.RefreshData();
         frmCaller.FindHeader("RowID", _rowID.ToString());
     }
 }
Exemplo n.º 2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                try
                {
                    switch (formMode)
                    {
                    case enumFormMode.New:

                        string doc      = "NOMOR_POTONGAN";
                        string depan    = "";
                        string belakang = "";
                        string NoPot    = "";
                        int    iNomor;
                        int    lebar;

                        depan = Tools.GeneralInitial();
                        DataTable dtNum = Tools.GetGeneralNumerator(doc);
                        lebar    = int.Parse(Tools.isNull(dtNum.Rows[0]["Lebar"], "0").ToString());
                        belakang = dtNum.Rows[0]["Belakang"].ToString();
                        if (Tools.isNull(dtNum.Rows[0]["Depan"], "").ToString() != depan)
                        {
                            iNomor = 1;
                        }
                        else
                        {
                            iNomor = int.Parse(dtNum.Rows[0]["Nomor"].ToString());
                            iNomor++;
                        }
                        NoPot         = Tools.FormatNumerator(iNomor, lebar, depan, belakang);
                        txtNoPot.Text = Tools.isNull(NoPot, "").ToString();

                        using (Database db = new Database())
                        {
                            DataTable dtCek = new DataTable();
                            db.Commands.Add(db.CreateCommand("usp_PenjualanPotongan_CEK"));
                            db.Commands[0].Parameters.Add(new Parameter("@notaPenjualanID", SqlDbType.UniqueIdentifier, _row));
                            dtCek = db.Commands[0].ExecuteDataTable();
                            if (dtCek.Rows.Count > 0)
                            {
                                MessageBox.Show("Nota ini sudah ada Potongan.");
                                return;
                            }
                        }

                        MessageBox.Show(trID.ToString());

                        using (Database db = new Database())
                        {
                            _rowID = Guid.NewGuid();
                            DataTable dt = new DataTable();
                            db.Commands.Add(db.CreateCommand("usp_PenjualanPotongan_INSERT"));
                            db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                            db.Commands[0].Parameters.Add(new Parameter("@notaPenjualanID", SqlDbType.UniqueIdentifier, _row));
                            db.Commands[0].Parameters.Add(new Parameter("@trID", SqlDbType.VarChar, trID));
                            db.Commands[0].Parameters.Add(new Parameter("@potID", SqlDbType.VarChar, Tools.CreateFingerPrint()));
                            db.Commands[0].Parameters.Add(new Parameter("@noPot", SqlDbType.VarChar, txtNoPot.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@tglPot", SqlDbType.DateTime, txtTglPot.DateValue));
                            db.Commands[0].Parameters.Add(new Parameter("@dil", SqlDbType.Money, Convert.ToDouble(txtPotLumRp.Text)));
                            db.Commands[0].Parameters.Add(new Parameter("@disc", SqlDbType.Money, Convert.ToDouble(txtPotLumPersen.Text)));
                            db.Commands[0].Parameters.Add(new Parameter("@rpNet", SqlDbType.Money, Convert.ToDouble(txtNetto.Text)));
                            db.Commands[0].Parameters.Add(new Parameter("@catatan", SqlDbType.VarChar, txtCatPot.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@tglACC", SqlDbType.DateTime, SqlDateTime.Null));
                            db.Commands[0].Parameters.Add(new Parameter("@dilACC", SqlDbType.Money, 0));
                            db.Commands[0].Parameters.Add(new Parameter("@catACC", SqlDbType.VarChar, ""));
                            db.Commands[0].Parameters.Add(new Parameter("@discACC", SqlDbType.Money, 0));
                            db.Commands[0].Parameters.Add(new Parameter("@syncFlag", SqlDbType.Bit, 0));
                            db.Commands[0].Parameters.Add(new Parameter("@idLink", SqlDbType.VarChar, ""));
                            db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 0));
                            db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();

                            db.Commands.Add(db.CreateCommand("usp_Numerator_UPDATE"));
                            db.Commands[1].Parameters.Add(new Parameter("@doc", SqlDbType.VarChar, doc));
                            db.Commands[1].Parameters.Add(new Parameter("@depan", SqlDbType.VarChar, depan));
                            db.Commands[1].Parameters.Add(new Parameter("@belakang", SqlDbType.VarChar, belakang));
                            db.Commands[1].Parameters.Add(new Parameter("@nomor", SqlDbType.Int, iNomor));
                            db.Commands[1].Parameters.Add(new Parameter("@lebar", SqlDbType.VarChar, lebar));
                            db.Commands[1].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[1].ExecuteNonQuery();
                        }
                        break;

                    case enumFormMode.Update:
                        if (txtTglACC.DateValue.HasValue)
                        {
                            GlobalVar.LastClosingDate = (DateTime)txtTglACC.DateValue;
                            if ((DateTime)txtTglACC.DateValue <= GlobalVar.LastClosingDate)
                            {
                                throw new Exception(String.Format(ISA.Trading.Messages.Error.AlreadyClosingPJT, GlobalVar.LastClosingDate));
                            }
                        }

                        using (Database db = new Database())
                        {
                            DataTable dt = new DataTable();
                            db.Commands.Add(db.CreateCommand("usp_PenjualanPotongan_UPDATE"));
                            db.Commands[0].Parameters.Add(new Parameter("@rowID", SqlDbType.UniqueIdentifier, _rowID));
                            db.Commands[0].Parameters.Add(new Parameter("@notaPenjualanID", SqlDbType.UniqueIdentifier, _row));
                            db.Commands[0].Parameters.Add(new Parameter("@trID", SqlDbType.VarChar, trID));
                            db.Commands[0].Parameters.Add(new Parameter("@potID", SqlDbType.VarChar, potID));
                            db.Commands[0].Parameters.Add(new Parameter("@noPot", SqlDbType.VarChar, txtNoPot.Text));
                            db.Commands[0].Parameters.Add(new Parameter("@tglPot", SqlDbType.DateTime, txtTglPot.DateValue));
                            db.Commands[0].Parameters.Add(new Parameter("@dil", SqlDbType.Money, Convert.ToDouble(txtPotLumRp.Text)));
                            //db.Commands[0].Parameters.Add(new Parameter("@disc", SqlDbType.Money, Convert.ToDouble(txtPotLumPersen.Text)));
                            db.Commands[0].Parameters.Add(new Parameter("@rpNet", SqlDbType.Money, Convert.ToDouble(txtNetto.Text)));
                            db.Commands[0].Parameters.Add(new Parameter("@catatan", SqlDbType.VarChar, txtCatPot.Text));
                            if (ajukan == true)
                            {
                                db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 0));
                            }
                            else if (acc == true)
                            {
                                if (Convert.ToDouble(txtACCRp.Text) > 0)
                                {
                                    db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 1));
                                }
                                else
                                {
                                    db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 0));
                                }
                            }
                            db.Commands[0].Parameters.Add(new Parameter("@syncFlag", SqlDbType.Bit, 0));
                            db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();

                            //db.Commands[0].Parameters.Add(new Parameter("@idLink", SqlDbType.VarChar, ""));
                            //db.Commands[0].Parameters.Add(new Parameter("@discACC", SqlDbType.Decimal, Convert.ToDecimal(txtACCPersen.Text)));
                            //db.Commands[0].Parameters.Add(new Parameter("@tglACC", SqlDbType.DateTime, txtTglACC.DateValue));
                            //db.Commands[0].Parameters.Add(new Parameter("@dilACC", SqlDbType.Money, Math.Round(Convert.ToDouble(txtACCRp.Text), 0)));
                            //db.Commands[0].Parameters.Add(new Parameter("@catACC", SqlDbType.VarChar, txtCatACC.Text));
                        }

                        //if (LookupInfo.GetValue("INSTALL_MODULE", "PIUTANG").ToString() == "True")
                        //{
                        //    if (ajukan == false)
                        //    {
                        //        if (acc == true && txtACCRp.GetDoubleValue > 0)
                        //        {
                        //            LinkToPiutang();
                        //        }
                        //    }
                        //}
                        break;
                    }
                    MessageBox.Show("Data telah tersimpan");
                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    Error.LogError(ex);
                }
                finally
                {
                    Penjualan.frmPotonganNotaBrowse frmCaller = (frmPotonganNotaBrowse)this.Caller;
                    frmCaller.RefreshData();
                    frmCaller.FindRow("RowID", _rowID.ToString());
                    this.Close();
                    frmCaller.Show();
                }
            }
        }