Esempio n. 1
0
 private void frmPenjualanPotonganUpdateISA_FormClosed_1(object sender, FormClosedEventArgs e)
 {
     if (this.DialogResult == DialogResult.OK)
     {
         if (this.Caller is frmPenjualanPotonganBrowser)
         {
             frmPenjualanPotonganBrowserISA frmCaller = (frmPenjualanPotonganBrowserISA)this.Caller;
             frmCaller.RefreshData();
             frmCaller.FindRow("RowID", _rowID.ToString());
         }
     }
 }
Esempio n. 2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            //if (SecurityManager.AppRole == "004")
            //    {
            if (IsValid())
            {
                try
                {
                    switch (formMode)
                    {
                    case enumFormMode.New:

                        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();
                        }

                        //);

                        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.Toko.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));
                            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 (ajukan == true)
                            {
                                db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 0));
                            }
                            else if (acc == true)
                            {
                                //cAcc = IIF(nDil_acc > 0,'v',' ')
                                if (Convert.ToDouble(txtACCRp.Text) > 0)
                                {
                                    db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 1));
                                    // LinkToPiutang();
                                }
                                else
                                {
                                    db.Commands[0].Parameters.Add(new Parameter("@statusACC", SqlDbType.Bit, 0));
                                }
                            }
                            db.Commands[0].Parameters.Add(new Parameter("@discACC", SqlDbType.Decimal, Convert.ToDecimal(txtACCPersen.Text)));
                            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("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                            db.Commands[0].ExecuteNonQuery();
                        }
                        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
                {
                    frmPenjualanPotonganBrowserISA frmCaller = (frmPenjualanPotonganBrowserISA)this.Caller;


                    frmCaller.RefreshData();
                    frmCaller.FindRow("RowID", _rowID.ToString());
                    this.Close();
                    frmCaller.Show();
                }
            }

            //}
        }