示例#1
0
 private void frmMasterFixSalesUpdate_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.Caller is frmMasterFixSales)
     {
         frmMasterFixSales ifrm = (frmMasterFixSales)this.Caller;
         ifrm.RefreshData();
         ifrm.FindRowHeader(_Rowid);
     }
 }
示例#2
0
        private void cbSave_Click(object sender, EventArgs e)
        {
            switch (formMode)
            {
            case enumFormMode.New:
                try
                {
                    DataTable dt = new DataTable();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_fixsales_Insert"));
                        db.Commands[0].Parameters.Add(new Parameter("@kodesales", SqlDbType.VarChar, lookupSales1.SalesID.ToString()));
                        db.Commands[0].Parameters.Add(new Parameter("@namasales", SqlDbType.VarChar, lookupSales1.NamaSales.ToString()));
                        if (checkBox1.Checked == true)
                        {
                            db.Commands[0].Parameters.Add(new Parameter("@idrec", SqlDbType.VarChar, "L"));
                        }
                        else
                        {
                            db.Commands[0].Parameters.Add(new Parameter("@idrec", SqlDbType.VarChar, " "));
                        }
                        db.Commands[0].Parameters.Add(new Parameter("@user", SqlDbType.VarChar, SecurityManager.UserID));
                        //dt = db.Commands[0].ExecuteDataTable();
                        Object hasil = db.Commands[0].ExecuteScalar();

                        if (hasil != null)
                        {
                            MessageBox.Show("Data gagal disimpan karena sales sudah pernah ditambahkan.");
                        }
                        else
                        {
                            MessageBox.Show("Data Berhasil Di simpan");
                            frmMasterFixSales frmCaller = (frmMasterFixSales)this.Caller;
                            frmCaller.RefreshData();
                            this.Close();
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    Error.LogError(ex);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
                break;

            case enumFormMode.Update:
                try
                {
                    DataTable dt = new DataTable();
                    using (Database db = new Database())
                    {
                        db.Commands.Add(db.CreateCommand("usp_fixSales_Edit"));
                        db.Commands[0].Parameters.Add(new Parameter("@rowid", SqlDbType.UniqueIdentifier, _Rowid));
                        db.Commands[0].Parameters.Add(new Parameter("@NamaSales", SqlDbType.VarChar, lookupSales1.NamaSales.ToString()));
                        db.Commands[0].Parameters.Add(new Parameter("@KodeSales", SqlDbType.VarChar, lookupSales1.SalesID.ToString()));
                        if (checkBox1.Checked == true)
                        {
                            db.Commands[0].Parameters.Add(new Parameter("@idrec", SqlDbType.VarChar, "L"));
                        }
                        else
                        {
                            db.Commands[0].Parameters.Add(new Parameter("@idrec", SqlDbType.VarChar, " "));
                        }
                        db.Commands[0].Parameters.Add(new Parameter("@LastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        dt = db.Commands[0].ExecuteDataTable();
                        MessageBox.Show("Data Berhasil Di simpan");
                        frmMasterFixSales frmCaller = (frmMasterFixSales)this.Caller;
                        frmCaller.RefreshData();
                        this.Close();
                    }
                }
                catch (System.Exception ex)
                {
                    Error.LogError(ex);
                    MessageBox.Show("Gagal Menyimpan Data");
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
                break;
            }
        }