Example #1
0
        private void save_company()
        {
            MainMenu frm = new MainMenu();
            //get data from table
            List <object[]> data = new List <object[]>();

            data = frm.get_data_table_string("tbcompany", "companyid", txtcompany.Text);
            String status = "Not Ada";

            if (data.Count > 0)
            {
                status = "Ada";
                //id=int.Parse(data[0][0].ToString());
            }
            String          connString = Konek();
            MySqlConnection conn5      = new MySqlConnection(connString);

            conn5.Open();
            try
            {
                MySqlCommand mySql3 = conn5.CreateCommand();
                mySql3.CommandText =
                    "Update tbcompany Set companyname=@companyname,owner=@owner,sex=@sex,licenseid=@licenseid,licenseexpdate=@licenseexpdate,address=@address,phone=@phone,provinceid=@provinceid,regencyid=@regencyid,districtid=@districtid,code=@code, comp_reg_no=@comp_reg_no, companyid=@companyid where id=@id";
                mySql3.Parameters.AddWithValue("@companyid", txtcompany.Text);
                mySql3.Parameters.AddWithValue("@companyname", txtcompanyname.Text);
                mySql3.Parameters.AddWithValue("@owner", txtowner.Text);
                String gender = "";
                if (rbmale.Checked)
                {
                    gender = "M";
                }
                else if (rbfemale.Checked)
                {
                    gender = "F";
                }


                List <object[]> dtarea = new List <object[]>();

                if (!cbProvinsi.Text.Equals(""))
                {
                    dtarea     = frm.get_data_table_string("provinces", "name", cbProvinsi.Text);
                    provinsiid = dtarea[0][0].ToString();
                }

                if (!cbKabupaten.Text.Equals(""))
                {
                    dtarea      = frm.get_data_table_string("regencies", "name", cbKabupaten.Text);
                    kabupatenid = dtarea[0][0].ToString();
                }

                if (!cbKecamatan.Text.Equals(""))
                {
                    dtarea      = frm.get_data_table_string("districts", "name", cbKecamatan.Text);
                    kecamatanid = dtarea[0][0].ToString();
                }


                mySql3.Parameters.AddWithValue("@sex", gender);
                mySql3.Parameters.AddWithValue("@licenseid", txtlicenseid.Text);
                DateTime expdate = dateTimePicker1.Value.Date;
                mySql3.Parameters.AddWithValue("@licenseexpdate", expdate);
                mySql3.Parameters.AddWithValue("@address", txtaddress.Text);
                mySql3.Parameters.AddWithValue("@phone", txtphone.Text);
                mySql3.Parameters.AddWithValue("@provinceid", provinsiid);
                mySql3.Parameters.AddWithValue("@regencyid", kabupatenid);
                mySql3.Parameters.AddWithValue("@districtid", kecamatanid);
                mySql3.Parameters.AddWithValue("@code", txtcode.Text);
                mySql3.Parameters.AddWithValue("@comp_reg_no", txtcompanyregistration.Text.Trim());
                mySql3.Parameters.AddWithValue("@id", id);
                mySql3.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error message " + ex.Message);
            }
            conn5.Close();
        }
Example #2
0
        private void save_vessel()
        {
            //String suppcode = "";
            MainMenu frm = new MainMenu();
            //get data from table
            List <object[]> data = new List <object[]>();

            data = frm.get_data_table_string_2param("tbvessel", "suppcode", this.suppcode.Text, "vesselname", vesselglobal);

            String status = "Not Ada";

            if (data.Count > 0)
            {
                status = "Ada";
            }

            String          connString = Konek();
            MySqlConnection conn5      = new MySqlConnection(connString);

            conn5.Open();

            MySqlCommand mySql3 = conn5.CreateCommand();

            if (status.Equals("Not Ada"))
            {
                try
                {
                    mySql3.CommandText =
                        "Insert into tbvessel(suppcode, vesselname, vesselsize, vesselregno, vessel_flag,expired_date,fishing_gear, fishing_aggregate_device, fishing_ground, fisherman)" +
                        " values(@suppcode, @vesselname, @vesselsize, @vesselregno, @vessel_flag,@expired_date,@fishing_gear,@fishing_aggregate_device, @fishing_ground,@fisherman)";

                    mySql3.Parameters.AddWithValue("@vesselname", txtvesselname.Text);
                    mySql3.Parameters.AddWithValue("@vesselsize", txtvesselsize.Text);
                    mySql3.Parameters.AddWithValue("@vesselregno", txtvesselregno.Text);
                    mySql3.Parameters.AddWithValue("@vessel_flag", txtflag.Text);
                    DateTime dt = dateTimePicker1.Value.Date;
                    mySql3.Parameters.AddWithValue("@expired_date", DateTime.Parse(dt.ToString("yyyy-MM-dd hh:mm:ss")));
                    mySql3.Parameters.AddWithValue("@fishing_gear", cbFishingGear.Text.Trim());
                    mySql3.Parameters.AddWithValue("@suppcode", this.suppcode.Text);
                    mySql3.Parameters.AddWithValue("@fisherman", this.txtfisherman.Text);

                    String fad = "N";
                    if (rbYes.Checked)
                    {
                        fad = "Y";
                    }
                    else
                    {
                        fad = "N";
                    }

                    mySql3.Parameters.AddWithValue("@fishing_aggregate_device", fad);
                    mySql3.Parameters.AddWithValue("@fishing_ground", cbfishing_ground.Text);
                    mySql3.ExecuteNonQuery();
                }catch (Exception ex)
                {
                    MessageBox.Show("Error message " + ex.Message);
                }
                conn5.Close();
            }


            if (flagedit == 1)
            {
                try
                {
                    mySql3.CommandText =
                        "update tbvessel set vesselname=@vesselname2, vesselsize=@vesselsize1, vesselregno=@vesselregno1, vessel_flag=@vessel_flag1, expired_date=@expired_date1, fishing_gear=@fishing_gear1, fishing_aggregate_device=@fishing_aggregate_device1, fishing_ground=@fishing_ground1 where suppcode=@suppcode1 and vesselname=@vesselname1";
                    mySql3.Parameters.AddWithValue("@vesselname1", vesselglobal);
                    mySql3.Parameters.AddWithValue("@vesselname2", txtvesselname.Text);
                    mySql3.Parameters.AddWithValue("@vesselsize1", txtvesselsize.Text);
                    mySql3.Parameters.AddWithValue("@vesselregno1", txtvesselregno.Text);
                    mySql3.Parameters.AddWithValue("@vessel_flag1", txtflag.Text);
                    DateTime dt = dateTimePicker1.Value.Date;
                    mySql3.Parameters.AddWithValue("@expired_date1", DateTime.Parse(dt.ToString("yyyy-MM-dd hh:mm:ss")));
                    mySql3.Parameters.AddWithValue("@fishing_gear1", cbFishingGear.Text.Trim());
                    mySql3.Parameters.AddWithValue("@suppcode1", this.suppcode.Text);

                    String fad = "N";
                    if (rbYes.Checked)
                    {
                        fad = "Y";
                    }
                    else
                    {
                        fad = "N";
                    }

                    mySql3.Parameters.AddWithValue("@fishing_aggregate_device1", fad);
                    mySql3.Parameters.AddWithValue("@fishing_ground1", cbfishing_ground.Text);
                    mySql3.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error message " + ex.Message);
                }
                conn5.Close();
                flagedit = 0;
            }
        }
Example #3
0
        public String Konek()
        {
            MainMenu frm = new MainMenu();

            return(frm.Konek());
        }
Example #4
0
        private void seticon_forbutton()
        {
            MainMenu frm = new MainMenu();

            frm.setbuttonicon_top("save", btnsave);
        }