예제 #1
0
        private void doStuff()
        {
            try
            {
                using (clsConnection oConn = new clsConnection())
                {
                    string carId      = Convert.ToString(gridViewData.GetFocusedRowCellValue(colCarId));
                    string platnumber = Convert.ToString(gridViewData.GetFocusedRowCellValue(colPlatnumber));
                    string strCount   = clsGlobal.getData1Field("select count(*) from tbm_car where dlt='0' and trim(lower(platnumber))=trim(lower('" + platnumber + "')) and carid <>'" + carId + "'");
                    if (Convert.ToInt32(strCount) == 0)
                    {
                        tbm_car oObject = new tbm_car();
                        oConn.Open();
                        oObject.Koneksi = oConn.Conn;
                        if (!string.IsNullOrEmpty(carId))
                        {
                            oObject.GetByPrimaryKey(carId);
                        }


                        oObject.carid = carId;
                        if (string.IsNullOrEmpty(carId))
                        {
                            oObject.carid = oObject.NewID();
                            oObject.opadd = clsGlobal.strUserName;
                            oObject.pcadd = SystemInformation.ComputerName;
                            oObject.luadd = DateTime.Now;
                            oObject.Insert();
                        }
                        else
                        {
                            oObject.available = status;
                            oObject.opedit    = clsGlobal.strUserName;
                            oObject.pcedit    = SystemInformation.ComputerName;
                            oObject.luedit    = DateTime.Now;
                            oObject.Update();
                        }
                    }
                    else
                    {
                    }
                }
            }

            catch (NpgsqlException ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (XtraMessageBox.Show(this, "Do you want to save this data?", clsGlobal.pstrAppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                loadImage();
                if (txtPlatnumber.Text == "" || txtPathText.Text == "" || cmbTipe.Text == "" || txtkapasitas.Value <= 1 || txtHarga.Text == "" || txtDesc.Text == "")
                {
                    XtraMessageBox.Show("Data Can't Be Null", "Warning");
                }
                else
                {
                    getTypeid();
                    try
                    {
                        using (clsConnection oConn = new clsConnection())
                        {
                            string strCount = clsGlobal.getData1Field("select count(*) from tbm_car where dlt='0' and trim(lower(platnumber))=trim(lower('" + txtPlatnumber.Text + "')) and carid <>'" + CarId + "'");
                            if (Convert.ToInt32(strCount) == 0)
                            {
                                tbm_car oObject = new tbm_car();
                                oConn.Open();
                                oObject.Koneksi = oConn.Conn;


                                if (!string.IsNullOrEmpty(CarId))
                                {
                                    oObject.GetByPrimaryKey(CarId);
                                }

                                oObject.carid      = m_carid;
                                oObject.platnumber = txtPlatnumber.Text;

                                oObject.typeid       = typeid;
                                oObject.description  = txtDesc.Text;
                                oObject.capacity     = Convert.ToInt32(txtkapasitas.Value);
                                oObject.price        = Convert.ToInt32(txtHarga.Text);
                                oObject.filepath_car = txtPathText.Text;

                                if (pathText == null)
                                {
                                    pathText = getImage;
                                }


                                oObject.image_car = pathText;

                                if (string.IsNullOrEmpty(CarId))
                                {
                                    oObject.carid     = oObject.NewID();
                                    oObject.available = true;
                                    oObject.opadd     = clsGlobal.strUserName;
                                    oObject.pcadd     = SystemInformation.ComputerName;
                                    oObject.Insert();
                                    XtraMessageBox.Show("Data Has been Inserted", clsGlobal.pstrAppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    oObject.opedit = clsGlobal.strUserName;
                                    oObject.pcedit = SystemInformation.ComputerName;
                                    oObject.Update();
                                    XtraMessageBox.Show("Data Has been Updated", clsGlobal.pstrAppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                    //catch { }
                    catch (NpgsqlException ex)
                    {
                        XtraMessageBox.Show(ex.Message);
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message);
                    }
                    this.Close();
                    clsGlobal.isClose = true;
                }
            }
            else
            {
            }
        }