コード例 #1
0
ファイル: UCRepair.cs プロジェクト: hanggaa/MobiloRentalAPP
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (XtraMessageBox.Show(this, "Are you sure to delete selected record?", clsGlobal.pstrAppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             using (clsConnection oConn = new clsConnection())
             {
                 frmMain.setLoadDialog(true, "Deleting data...");
                 tbm_carrepair oObject = new tbm_carrepair();
                 oConn.Open();
                 oObject.Koneksi  = oConn.Conn;
                 oObject.repairid = Convert.ToString(dgData.CurrentRow.Cells["repairid"].Value.ToString());
                 oObject.opedit   = clsGlobal.strUserName;
                 oObject.pcedit   = SystemInformation.ComputerName;
                 oObject.Delete();
                 oObject = null;
             }
         }
         catch (NpgsqlException ex)
         {
         }
         catch (Exception ex)
         {
             ////clsGlobal.generateErrMessageAndSendmail(ex, false);
         }
         finally
         {
             frmMain.setLoadDialog(false, "");
             loadData();
         }
     }
 }
コード例 #2
0
ファイル: UCRepair.cs プロジェクト: hanggaa/MobiloRentalAPP
        private void btnSave_Click(object sender, EventArgs e)
        {
            getRepairId();
            if (cmbPlatnumber.Text == "")
            {
                MessageBox.Show("Please Provide The Car ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    using (clsConnection oConn = new clsConnection())
                    {
                        string strGetCarid = clsGlobal.getData1Field("select carid from tbm_car where platnumber='" + cmbPlatnumber.Text + "'");
                        string strCount    = clsGlobal.getData1Field("select count(*) from tbm_carrepair where dlt='0' and trim(lower(carid))=trim(lower('" + strGetCarid + "')) and repairid <>'" + strRepairid + "'");
                        if (Convert.ToInt32(strCount) == 0)
                        {
                            tbm_carrepair oObject = new tbm_carrepair();
                            oConn.Open();
                            oObject.Koneksi = oConn.Conn;
                            if (!string.IsNullOrEmpty(strRepairid))
                            {
                                oObject.GetByPrimaryKey(strRepairid);
                            }
                            oObject.repairid = strRepairid;
                            oObject.carid    = strGetCarid;

                            if (oObject.carid == "")
                            {
                                XtraMessageBox.Show("Data Can't Be Null", "Warning");
                            }
                            else
                            {
                                oObject.repairid = strRepairid;
                                oObject.opadd    = clsGlobal.strUserName;
                                oObject.pcadd    = SystemInformation.ComputerName;
                                oObject.luadd    = DateTime.Now;
                                oObject.Insert();
                                Clear();
                                loadData();
                                MessageBox.Show("Data Inserted", "Insert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                oObject = null;
                            }
                        }
                        else
                        {
                        }
                    }
                }
                catch (NpgsqlException ex)
                {
                    ////clsGlobal.generateErrMessageAndSendmail(ex, false);
                }
                catch (Exception ex)
                {
                    ////clsGlobal.generateErrMessageAndSendmail(ex, false);
                }
            }
        }