示例#1
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                switch (formMode)
                {
                case enumFormMode.New:

                    using (Database db = new Database())
                    {
                        db.Open();

                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_Numerator_INSERT"));

                        db.Commands[0].Parameters.Add(new Parameter("@doc", SqlDbType.VarChar, txtDoc.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@depan", SqlDbType.VarChar, txtDepan.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@belakang", SqlDbType.VarChar, txtBelakang.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@nomor", SqlDbType.Int, txtNomor.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@lebar", SqlDbType.Int, txtLebar.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        db.Close();
                        db.Dispose();
                    }
                    break;

                case enumFormMode.Update:
                    using (Database db = new Database())
                    {
                        db.Open();

                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_Numerator_UPDATE"));
                        db.Commands[0].Parameters.Add(new Parameter("@doc", SqlDbType.VarChar, txtDoc.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@depan", SqlDbType.VarChar, txtDepan.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@belakang", SqlDbType.VarChar, txtBelakang.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@nomor", SqlDbType.Int, txtNomor.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@lebar", SqlDbType.Int, txtLebar.GetIntValue));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        db.Close();
                        db.Dispose();
                    }
                    break;
                }
                MessageBox.Show("Data telah tersimpan");
                this.DialogResult = DialogResult.OK;
                frmNumeratorBrowse frmCaller = (frmNumeratorBrowse )this.Caller;
                frmCaller.Refreshdata();
                this.Close();
                frmCaller.Show();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }
示例#2
0
 private void frmNumeratorUpdate_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.DialogResult == DialogResult.OK)
     {
         if (this.Caller is frmNumeratorBrowse)
         {
             frmNumeratorBrowse frmCaller = (frmNumeratorBrowse)this.Caller;
             frmCaller.Refreshdata();
             frmCaller.FindRow("Doc", txtDoc.Text);
         }
     }
 }