Exemplo n.º 1
0
 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_customer oObject = new tbm_customer();
                 oConn.Open();
                 oObject.Koneksi    = oConn.Conn;
                 oObject.customerid = Convert.ToString(gridViewData.GetFocusedRowCellValue(colCustomerid));
                 oObject.opedit     = clsGlobal.strUserName;
                 oObject.pcedit     = SystemInformation.ComputerName;
                 oObject.SoftDelete();
                 oObject = null;
                 gridViewData.DeleteSelectedRows();
             }
         }
         catch (NpgsqlException ex)
         {
         }
         catch (Exception ex)
         {
             ////clsGlobal.generateErrMessageAndSendmail(ex, false);
         }
         finally
         {
             frmMain.setLoadDialog(false, "");
         }
     }
 }
Exemplo n.º 2
0
        private void gridViewData_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                using (clsConnection oConn = new clsConnection())
                {
                    string customerid = Convert.ToString(gridViewData.GetFocusedRowCellValue(colCustomerid));
                    string strCount   = clsGlobal.getData1Field("select count(*) from tbm_customer where dlt='0' and trim(lower(name))=trim(lower('" + Convert.ToString(gridViewData.GetFocusedRowCellValue(colName)) + "')) and customerid <>'" + customerid + "'");
                    if (Convert.ToInt32(strCount) == 0)
                    {
                        tbm_customer oObject = new tbm_customer();
                        oConn.Open();
                        oObject.Koneksi = oConn.Conn;
                        if (!string.IsNullOrEmpty(customerid))
                        {
                            oObject.GetByPrimaryKey(customerid);
                        }
                        oObject.customerid      = Convert.ToString(gridViewData.GetFocusedRowCellValue(colCustomerid));
                        oObject.name            = Convert.ToString(gridViewData.GetFocusedRowCellValue(colName));
                        oObject.identity_type   = Convert.ToString(gridViewData.GetFocusedRowCellValue(colIdentityType));
                        oObject.identity_number = Convert.ToString(gridViewData.GetFocusedRowCellValue(colIdentityNumber));
                        oObject.gender          = Convert.ToString(gridViewData.GetFocusedRowCellValue(colGender));
                        oObject.phoneNumber     = Convert.ToDecimal(gridViewData.GetFocusedRowCellValue(colPhoneNumber));
                        oObject.dob             = Convert.ToDateTime(gridViewData.GetFocusedRowCellValue(colDob));
                        oObject.address         = Convert.ToString(gridViewData.GetFocusedRowCellValue(colAddress));

                        if (oObject.name == "")
                        {
                            XtraMessageBox.Show("Data Can't Be Null", "Warning");
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(customerid))
                            {
                                oObject.customerid = oObject.NewID();
                                oObject.opadd      = clsGlobal.strUserName;
                                oObject.pcadd      = SystemInformation.ComputerName;
                                oObject.luadd      = DateTime.Now;
                                oObject.Insert();
                                gridViewData.SetFocusedRowCellValue(colCustomerid, oObject.customerid);
                            }
                            else
                            {
                                oObject.opedit = clsGlobal.strUserName;
                                oObject.pcedit = SystemInformation.ComputerName;
                                oObject.luedit = DateTime.Now;
                                oObject.Update();
                            }
                            oObject = null;
                            e.Valid = true;
                        }
                    }
                    else
                    {
                        e.ErrorText = "This code " + Convert.ToString(gridViewData.GetFocusedRowCellValue(colName)) + " already exists in database and cannot be filled the same value.!\n";
                        gridViewData.FocusedColumn = colName;
                        e.Valid = false;
                        return;
                    }
                }
            }
            catch (NpgsqlException ex)
            {
                ////clsGlobal.generateErrMessageAndSendmail(ex, false);
            }
            catch (Exception ex)
            {
                ////clsGlobal.generateErrMessageAndSendmail(ex, false);
            }
        }