Aydotcom Ответов: 1

Неправильный синтаксис рядом с ключевым словом ' '


я сохранял данные в таблицу с помощью C# и sql, но столкнулся с ошибкой "не сохранить: неправильный синтаксис рядом с ключевым словом "обзор". Кто-нибудь может мне помочь?

Что я уже пробовал:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Data.SqlTypes;


namespace FHAMortgageBank
{
    public partial class Add_Employee : Form
    {
      //double bsal=double.Parse()
        //double bsal = double.Parse(txtBSal.Text);
        //double tranA = double.Parse(txtTran.Text);
        //double tpay = double.Parse(txtTPay.Text);

        // string ;
        public Add_Employee()
        {
            InitializeComponent();
            double bsal, tranA, hous, lunc, uti, furn, harz, educ, housM, dres, risk, veh, driv, dome, pfs, nhf, nhfs, oded, housU, staffM, thrift, otherP, Nhis, pens, paye, tpay, tded, npay;
       
            ClearData();// Method
            FillBank();
            FillStatus();
            FillPenAdmin();
            FillYear();
            FillGrade();
            FillDpt();
            New_Rec();
            DisplayData();
            New_Rec();
            Calculation();
            
            //StaffParameter();
           // this.picStafPix.Image = Properties.Resources.DefaultPicture;

        }
        //public void calculateTotal()
        //{

        //}
        public static string constring = "Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True";
        
         SqlConnection con = new SqlConnection("Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True");
        SqlCommand cmd;
        //SqlDataAdapter adapt;
        SqlDataReader dreader;
        SqlDataAdapter adapt = new SqlDataAdapter();
        private DataViewManager dviewmanager;

        int SN = 0;
        //double bsal; bsal;double tranA;double hous;double lunc;uti;furn;harz;educ;housM;dres;risk;veh;driv;dome;pfs;nhf;nhfs;oded;housU;staffM;thrift;otherP;Nhis;pens;paye;tded;tpay;npay;
        
        private void frmMain_Enter(object sender, EventArgs e)
        {

        }
        

        private void picStafPix_Click(object sender, EventArgs e)
        {
            //this.picStafPix.Image = Image.FromFile(@"Images\a.bmp");
        }

        private void button1_Click(object sender, EventArgs e)
        {
       
            // open file dialog   
            OpenFileDialog open = new OpenFileDialog();
            // image filters  
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
            {
                // display image in picture box  
                this.picStafPix.Image = new Bitmap(open.FileName);
                // image file path  
                textBox1.Text = open.FileName;

            }
        }
        private void Calculation()
        {
        //    double bsal = Convert.ToInt32(txtBSal.Text);
        //    double hous = Convert.ToInt32(txtHous.Text);
        //    double tpay = bsal + hous;
        //    txtTPay.Text = tpay.ToString();
                      
            //double temp2 = double.Parse(textBox2.Text);
            //txtTPay.Text += tpay; txtBSal.Text += bsal; txtTran.Text += tranA; txtHous.Text += hous; txtLunc.Text += lunc;
            //txtDres.Text += dres; txtFurn.Text += furn; txtHarz.Text += harz; txtEduc.Text += educ; txtRisk.Text += risk;
            //txtVeh.Text += veh; txtDriv.Text += driv; txtDome.Text += dome; txtOtherPay.Text += otherP; txtUti.Text += uti; txtHousM.Text += housM;
            ////bsal = Convert.ToInt32(txtBSal.Text); tpay = Convert.ToInt32(txtTPay.Text); tranA = Convert.ToInt32(txtTran.Text);
            //////  tpay =bsal + tranA + hous+lunc+uti+furn+harz+educ+housM+dres+risk+veh+driv+dome+otherP;
            //////   tpay = bsal + tranA ;
            ////// txtTPay.Text =tpay.ToString();
            ////// txtTPay.Text = (Convert.ToInt32(txtBSal.Text) + Convert.ToInt32(txtTran.Text).ToString());
            //////  txtTPay.Text = convert.toString(Convert.ToInt32(txtBSal.Text) + Convert.ToInt32(txtTran.Text)).toString();
            //txtTPay.Text = Convert.ToString((Convert.ToInt32(txtBSal.Text) + Convert.ToInt32(txtTran.Text) + Convert.ToInt32(txtHous.Text) + Convert.ToInt32(txtLunc.Text) + Convert.ToInt32(txtUti.Text) + Convert.ToInt32(txtFurn.Text) + Convert.ToInt32(txtHarz.Text) + Convert.ToInt32(txtEduc.Text) + Convert.ToInt32(txtHousM.Text) + Convert.ToInt32(txtDres.Text) + Convert.ToInt32(txtRisk.Text) + Convert.ToInt32(txtVeh.Text) + Convert.ToInt32(txtDriv.Text) + Convert.ToInt32(txtDome.Text) + Convert.ToInt32(txtOtherPay.Text)));


            ////TextBox3.Text = result.ToString(); 
        }


        //public frmMain()
        //{
          
        //}

        private void BntSave_Click(object sender, EventArgs e)
        {

            //if (txteid.Text != "" && txtStaf.Text != "")
            //{
            //    MessageBox.Show("Please enter valid data...");
            //}
            //else

            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter valid data...");
            }
            else
           
            {
                //FileStream fs = new FileStream(textBox1.Text, FileMode.OpenOrCreate, FileAccess.Read);
                //byte[] bt = new byte[fs.Length];
                //fs.Read(bt, 0, System.Convert.ToInt32(fs.Length));
                //fs.Close();
                Image img = this.picStafPix.Image;
                byte[] bt;
                ImageConverter converter = new ImageConverter();
                bt = (byte[])converter.ConvertTo(img, typeof(byte[]));
               // System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                //cmd.CommandType = System.Data.CommandType.Text;
                SqlConnection con = new SqlConnection();
               con.ConnectionString = "Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True";
               cmd = new SqlCommand("insert into master (eid,mon,yr,dat,staf,adrs,coy,loc,dpt,grd,datead,datemod,bsal,tranA,hous,lunc,uti,furn,harz,educ,housM,dres,risk,veh,driv,dome,pfs,nhf,nhfs,oded,housU,staffM,thrift,otherP,accno,bank,email,penadmin,pennum,status,Nhis,picstaffpix,photo,browse) values(@eid, @mon,@yr,@dat,@staf,@adrs,@coy,@loc,@dpt,@grd,@datead,@datemod,@bsal,@tran,@hous,@lunc,@uti,@furn,@harz,@educ,@housM,@dres,@risk,@veh,@driv,@dome,@pfs,@nhf,@nhfs,@oded,@housU,@staffM,@thrift,@otherP,@accno,@bank,@email,@penadmin,@pennum,@status,@Nhis,@picstaffpix,@photo, @BrowsePic )", con);
              // cmd = new SqlCommand("insert into master (eid,mon,yr,dat,staf,adrs,coy,loc,dpt,grd,datead,datemod,bsal,tranA,hous,lunc,uti,furn,harz,educ,housM,dres,risk,veh,driv,dome,pfs,nhf,nhfs,oded,housU,staffM,thrift,otherP,accno,bank,email,penadmin,pennum,status,Nhis,picstaffpix,photo) values(@eid, @mon,@yr,@dat,@staf,@adrs,@coy,@loc,@dpt,@grd,@datead,@datemod,@bsal,@tran,@hous,@lunc,@uti,@furn,@harz,@educ,@housM,@dres,@risk,@veh,@driv,@dome,@pfs,@nhf,@nhfs,@oded,@housU,@staffM,@thrift,@otherP,@accno,@bank,@email,@penadmin,@pennum,@status,@Nhis,@picstaffpix,@photo )", con);
                con.Open();
               // StaffParameter();
                            cmd.Parameters.AddWithValue("@eid", txteid.Text);
                          cmd.Parameters.AddWithValue("@yr", cmbYr.Text);
                          cmd.Parameters.AddWithValue("@dat", datAd.Text);
                          cmd.Parameters.AddWithValue("@datead", datEmp.Text);
                          cmd.Parameters.AddWithValue("@datemod", DatMod.Text);
                            cmd.Parameters.AddWithValue("@staf", txtStaf.Text);
                           cmd.Parameters.AddWithValue("@adrs", txtAdrs.Text);
                            cmd.Parameters.AddWithValue("@coy", txtCoy.Text);
                           cmd.Parameters.AddWithValue("@dpt", cmbDpt.Text);
                            cmd.Parameters.AddWithValue("@loc", cmbLoc.Text);
                            cmd.Parameters.AddWithValue("@grd", CmbGrd.Text);
                            cmd.Parameters.AddWithValue("@accno", TxtAccno.Text);
                            cmd.Parameters.AddWithValue("@email", txtemail.Text);
                            cmd.Parameters.AddWithValue("@picstaffpix", bt);
                            cmd.Parameters.AddWithValue("@bank", cmbBank.Text);
                            cmd.Parameters.AddWithValue("@penadmin", cmbPenAdmin.Text);
                            cmd.Parameters.AddWithValue("@status", cmbStatus.Text);
                           cmd.Parameters.AddWithValue("@pennum", txtPenNum.Text);
                            cmd.Parameters.AddWithValue("@bsal", txtBSal.Text);
                            cmd.Parameters.AddWithValue("@dres", txtDres.Text);
                           cmd.Parameters.AddWithValue("@Nhis", txtNhis.Text);
                           cmd.Parameters.AddWithValue("@educ", txtEduc.Text);
                           cmd.Parameters.AddWithValue("@furn", txtFurn.Text);
                           cmd.Parameters.AddWithValue("@harz", txtHarz.Text);
                            cmd.Parameters.AddWithValue("@tran", txtTran.Text);
                            cmd.Parameters.AddWithValue("@hous", txtHous.Text);
                           cmd.Parameters.AddWithValue("@lunc", txtLunc.Text);
                            cmd.Parameters.AddWithValue("@uti", txtUti.Text);
                            cmd.Parameters.AddWithValue("@housM", txtHousM.Text);
                            cmd.Parameters.AddWithValue("@risk", txtRisk.Text);
                           cmd.Parameters.AddWithValue("@veh", txtVeh.Text);
                            cmd.Parameters.AddWithValue("@pfs", txtPfS.Text);
                            cmd.Parameters.AddWithValue("@nhf", txtNHF.Text);
                            cmd.Parameters.AddWithValue("@nhfs", txtNHFS.Text);
                            cmd.Parameters.AddWithValue("@oded", txtOded.Text);
                            cmd.Parameters.AddWithValue("@driv", txtDriv.Text);
                            cmd.Parameters.AddWithValue("@dome", txtDome.Text);
                            cmd.Parameters.AddWithValue("@housU", this.txtHousU.Text);
                            cmd.Parameters.AddWithValue("@staffM", this.txtStaffM.Text);
                            cmd.Parameters.AddWithValue("@thrift", this.txtThrift.Text);
                            cmd.Parameters.AddWithValue("@mon", cmbMon.Text);
                           cmd.Parameters.AddWithValue("@otherP", this.txtOtherPay.Text);
                           cmd.Parameters.AddWithValue("@photo", this.textBox1.Text);
                            cmd.Parameters.AddWithValue("@BrowsePic", this.button1.Text);
                          //  cmd.Parameters.AddWithValue("@BrowsePic", SqlDbType.NVarChar).Value=DBNull.Value;
                           // cmd.Parameters.Add("@BrowsePic", SqlDbType.NVarChar).Value = DBNull.Value;
                          //  cmd.Parameters.Add("@BrowsePic", SqlDbType.Int).Value = int.Parse(button1.Text);
                          // cmd.Parameters.Add("@d1", SqlDbType.Int).Value = int.Parse(txtMembershipID.Text);
                         // cmd.Parameters.AddWithValue("@BrowsePic", SqlDbType.NVarChar).Value = DBNull.Value;
                          // cmd.Parameters.AddWithValue("@BrowsePic", SqlDbType.NVarChar).Value =  button1.Text;
                cmd.Connection = con;
               
                try
                {
                   int k = cmd.ExecuteNonQuery();
                    MessageBox.Show("Saved...");
                    
                    ClearData();// Method

                    // textBox1.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Not Save:\n" + ex.Message);
                }
                finally
                {
                    con.Close();
                }
            }
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //if (txteid.Text != "" && txtStaf.Text != "")
            //{
            //    MessageBox.Show("Please enter valid data...");
            //}
            //else
            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter valid data...");
            }
            else
            {
                //FileStream fs = new FileStream(textBox1.Text, FileMode.OpenOrCreate, FileAccess.Read);
                //byte[] bt = new byte[fs.Length];
                //fs.Read(bt, 0, System.Convert.ToInt32(fs.Length));
                //fs.Close();
                Image img = this.picStafPix.Image;
                byte[] bt;
                ImageConverter converter = new ImageConverter();
                bt = (byte[])converter.ConvertTo(img, typeof(byte[]));
                System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                SqlDataAdapter adapt = new SqlDataAdapter();
                SqlConnection con = new SqlConnection();
                con.ConnectionString = "Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True";
                cmd = new SqlCommand("update master set mon=@Mon , yr=@Yr, dat=@dat,staf=@Staf,adrs=@Adrs,coy=@Coy,loc=@Loc,dpt=@Dpt,grd= @Grd,datead=@datead,datemod=@datemod,bsal=@BSal,tranA=@Tran,hous=@Hous,lunc=@Lunc,uti=@Uti,furn=@Furn,harz=@Harz,educ=@Educ,housM=@HousM,dres=@Dres,risk=@Risk,veh=@Veh,driv=@Driv,dome=@Dome,pfs=@PfS,nhf=@NHF,nhfs=@NHFS,oded=@Oded,housU=@HousU,staffM=@StaffM,thrift=@Thrift,accno=@Accno,bank= @Bank,email=@email,penadmin=@PenAdmin,pennum=@PenNum,status=@Status,Nhis=@Nhis,picstaffpix=@picstaffpix WHERE eid= @eid ", con);
                con.Open();
               // StaffParameter();
                cmd.Parameters.AddWithValue("@eid", txteid.Text);
                cmd.Parameters.AddWithValue("@yr", cmbYr.Text);
                cmd.Parameters.AddWithValue("@dat", datAd.Text);
                cmd.Parameters.AddWithValue("@datead", datEmp.Text);
                cmd.Parameters.AddWithValue("@datemod", DatMod.Text);
                cmd.Parameters.AddWithValue("@staf", txtStaf.Text);
                cmd.Parameters.AddWithValue("@adrs", txtAdrs.Text);
                cmd.Parameters.AddWithValue("@coy", txtCoy.Text);
                cmd.Parameters.AddWithValue("@dpt", cmbDpt.Text);
                cmd.Parameters.AddWithValue("@loc", cmbLoc.Text);
                cmd.Parameters.AddWithValue("@grd", CmbGrd.Text);
                cmd.Parameters.AddWithValue("@accno", TxtAccno.Text);
                cmd.Parameters.AddWithValue("@email", txtemail.Text);
                cmd.Parameters.AddWithValue("@picstaffpix", bt);
                cmd.Parameters.AddWithValue("@bank", cmbBank.Text);
                cmd.Parameters.AddWithValue("@penadmin", cmbPenAdmin.Text);
                cmd.Parameters.AddWithValue("@status", cmbStatus.Text);
                cmd.Parameters.AddWithValue("@pennum", txtPenNum.Text);
                cmd.Parameters.AddWithValue("@bsal", txtBSal.Text);
                cmd.Parameters.AddWithValue("@dres", txtDres.Text);
                cmd.Parameters.AddWithValue("@Nhis", txtNhis.Text);
                cmd.Parameters.AddWithValue("@educ", txtEduc.Text);
                cmd.Parameters.AddWithValue("@furn", txtFurn.Text);
                cmd.Parameters.AddWithValue("@harz", txtHarz.Text);
                cmd.Parameters.AddWithValue("@tran", txtTran.Text);
                cmd.Parameters.AddWithValue("@hous", txtHous.Text);
                cmd.Parameters.AddWithValue("@lunc", txtLunc.Text);
                cmd.Parameters.AddWithValue("@uti", txtUti.Text);
                cmd.Parameters.AddWithValue("@housM", txtHousM.Text);
                cmd.Parameters.AddWithValue("@risk", txtRisk.Text);
                cmd.Parameters.AddWithValue("@veh", txtVeh.Text);
                cmd.Parameters.AddWithValue("@pfs", txtPfS.Text);
                cmd.Parameters.AddWithValue("@nhf", txtNHF.Text);
                cmd.Parameters.AddWithValue("@nhfs", txtNHFS.Text);
                cmd.Parameters.AddWithValue("@oded", txtOded.Text);
                
                cmd.Parameters.AddWithValue("@driv", txtDriv.Text);
                cmd.Parameters.AddWithValue("@dome", txtDome.Text);
                cmd.Parameters.AddWithValue("@housU", this.txtHousU.Text);
                cmd.Parameters.AddWithValue("@staffM", this.txtStaffM.Text);
                cmd.Parameters.AddWithValue("@thrift", this.txtThrift.Text);
                cmd.Parameters.AddWithValue("@mon", cmbMon.Text);
                cmd.Parameters.AddWithValue("@otherP", this.txtOtherPay.Text);
                cmd.Parameters.AddWithValue("@photo", this.textBox1.Text);
                cmd.Parameters.AddWithValue("@BrowsePic", this.button1.Text);

                  adapt.UpdateCommand = cmd;

                cmd.Connection = con;
                try
                {
                    int k = cmd.ExecuteNonQuery();
                    MessageBox.Show("Updated...");
                    ClearData();// Method
                    //textBox1.Text = "";

                }

                catch (Exception ex)
                {
                    MessageBox.Show("Not Updated:\n" + ex.Message);
                }
                finally
                {
                    con.Close();
                }
            }


        }

        private void btnSearch_Click(object sender, EventArgs e)
        {

            // if (txteid.Text != "" && txtStaf.Text != "")
            //{
            //    MessageBox.Show("Please enter valid data...");
            //}
            //else
            if (textBox1.Text == "")
            { }
            else
            {
                //FileStream fs = new FileStream(textBox1.Text, FileMode.OpenOrCreate, FileAccess.Read);
                //byte[] bt = new byte[fs.Length];
                //fs.Read(bt, 0, System.Convert.ToInt32(fs.Length));
                //fs.Close();
                Image img = this.picStafPix.Image;
                byte[] bt;
                ImageConverter converter = new ImageConverter();
                bt = (byte[])converter.ConvertTo(img, typeof(byte[]));
                SqlConnection con = new SqlConnection();
                //System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                //cmd.CommandType = System.Data.CommandType.Text;
                //SqlDataAdapter adapt = new SqlDataAdapter();
                con.ConnectionString = "Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True";
                //SqlCommand cmd = new SqlCommand("delete master where  txteid.Text =@eid", con);
                cmd = new SqlCommand("select * from master where eid =@eid", con);
                con.Open();
                cmd.Parameters.AddWithValue("@eid", txteid.Text);
                //cmd.Parameters.AddWithValue("@picstaffpix", bt);
                cmd.Connection = con;
                try
                {
                    dreader = cmd.ExecuteReader();
                    if (dreader.Read())
                    {
                        //txtname.Text = dreader[1].ToString(); 
                        txteid.Text = dreader[1].ToString();
                        cmbYr.Text = dreader[2].ToString();
                        datAd.Text = dreader[3].ToString();
                        datEmp.Text = dreader[4].ToString();
                        DatMod.Text = dreader[5].ToString();
                        txtStaf.Text = dreader[6].ToString();
                        txtAdrs.Text = dreader[7].ToString();
                        txtCoy.Text = dreader[8].ToString();
                        cmbDpt.Text = dreader[9].ToString();
                        cmbLoc.Text = dreader[10].ToString();
                        CmbGrd.Text = dreader[11].ToString();
                        TxtAccno.Text = dreader[12].ToString();
                        txtemail.Text = dreader[13].ToString();
                        // bt=dreader[14].ToString();
                        cmbBank.Text = dreader[15].ToString();
                        cmbPenAdmin.Text = dreader[16].ToString();
                        cmbStatus.Text = dreader[17].ToString();
                        txtPenNum.Text = dreader[18].ToString();
                        txtBSal.Text = dreader[19].ToString();
                        txtDres.Text = dreader[20].ToString();
                        txtNhis.Text = dreader[21].ToString();
                        txtEduc.Text = dreader[22].ToString();
                        txtFurn.Text = dreader[23].ToString();
                        txtHarz.Text = dreader[24].ToString();
                        txtTran.Text = dreader[25].ToString();
                        txtHous.Text = dreader[26].ToString();
                        txtLunc.Text = dreader[27].ToString();
                        txtUti.Text = dreader[28].ToString();
                        txtHousM.Text = dreader[29].ToString();
                        txtRisk.Text = dreader[30].ToString();
                        txtVeh.Text = dreader[31].ToString();
                        txtPfS.Text = dreader[32].ToString();
                        txtNHF.Text = dreader[33].ToString();
                        txtNHFS.Text = dreader[34].ToString();
                        txtOded.Text = dreader[35].ToString();
                        
                        txtDriv.Text = dreader[39].ToString();
                        txtDome.Text = dreader[40].ToString();
                       
                        txtHousU.Text = dreader[43].ToString();
                        txtStaffM.Text = dreader[44].ToString();
                        txtThrift.Text = dreader[45].ToString();
                        cmbMon.Text = dreader[46].ToString();
                        txtOtherPay.Text = dreader[47].ToString();
                        textBox1.Text = dreader[48].ToString();
                        button1.Text = dreader[49].ToString(); //txtname.Text = dreader[1].ToString();
                        //txtage.Text = dreader[2].ToString();
                        //txtcourse.Text = dreader[3].ToString();
                        ClearData();
                    }
                    else
                    {
                        MessageBox.Show(" No Record");
                    }
                    dreader.Close();
                }
                catch (Exception x)
                {
                    MessageBox.Show("No Record:\n" + x.Message);
                }
                finally
                {
                    con.Close();
                }
            }

        }

        private void btnDelete_Click(object sender, EventArgs e)
        {

            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter valid data...");
            }
            else
            {
                //FileStream fs = new FileStream(textBox1.Text, FileMode.OpenOrCreate, FileAccess.Read);
                //byte[] bt = new byte[fs.Length];
                //fs.Read(bt, 0, System.Convert.ToInt32(fs.Length));
                //fs.Close();
                Image img = this.picStafPix.Image;
                byte[] bt;
                ImageConverter converter = new ImageConverter();
                bt = (byte[])converter.ConvertTo(img, typeof(byte[]));
               // System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                //cmd.CommandType = System.Data.CommandType.Text;
                //SqlDataAdapter adapt = new SqlDataAdapter();
                SqlConnection con = new SqlConnection();
                con.ConnectionString = "Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True";
                //SqlCommand cmd = new SqlCommand("delete master where  txteid.Text =@eid", con);
                cmd = new SqlCommand("delete master where  eid =@eid", con);
                con.Open();
                //StaffParameter();
                cmd.Parameters.AddWithValue("@eid", txteid.Text);
                cmd.Parameters.AddWithValue("@yr", cmbYr.Text);
                cmd.Parameters.AddWithValue("@dat", datAd.Text);
                cmd.Parameters.AddWithValue("@datead", datEmp.Text);
                cmd.Parameters.AddWithValue("@datemod", DatMod.Text);
                cmd.Parameters.AddWithValue("@staf", txtStaf.Text);
                cmd.Parameters.AddWithValue("@adrs", txtAdrs.Text);
                cmd.Parameters.AddWithValue("@coy", txtCoy.Text);
                cmd.Parameters.AddWithValue("@dpt", cmbDpt.Text);
                cmd.Parameters.AddWithValue("@loc", cmbLoc.Text);
                cmd.Parameters.AddWithValue("@grd", CmbGrd.Text);
                cmd.Parameters.AddWithValue("@accno", TxtAccno.Text);
                cmd.Parameters.AddWithValue("@email", txtemail.Text);
                cmd.Parameters.AddWithValue("@picstaffpix", bt);
                cmd.Parameters.AddWithValue("@bank", cmbBank.Text);
                cmd.Parameters.AddWithValue("@penadmin", cmbPenAdmin.Text);
                cmd.Parameters.AddWithValue("@status", cmbStatus.Text);
                cmd.Parameters.AddWithValue("@pennum", txtPenNum.Text);
                cmd.Parameters.AddWithValue("@bsal", txtBSal.Text);
                cmd.Parameters.AddWithValue("@dres", txtDres.Text);
                cmd.Parameters.AddWithValue("@Nhis", txtNhis.Text);
                cmd.Parameters.AddWithValue("@educ", txtEduc.Text);
                cmd.Parameters.AddWithValue("@furn", txtFurn.Text);
                cmd.Parameters.AddWithValue("@harz", txtHarz.Text);
                cmd.Parameters.AddWithValue("@tran", txtTran.Text);
                cmd.Parameters.AddWithValue("@hous", txtHous.Text);
                cmd.Parameters.AddWithValue("@lunc", txtLunc.Text);
                cmd.Parameters.AddWithValue("@uti", txtUti.Text);
                cmd.Parameters.AddWithValue("@housM", txtHousM.Text);
                cmd.Parameters.AddWithValue("@risk", txtRisk.Text);
                cmd.Parameters.AddWithValue("@veh", txtVeh.Text);
                cmd.Parameters.AddWithValue("@pfs", txtPfS.Text);
                cmd.Parameters.AddWithValue("@nhf", txtNHF.Text);
                cmd.Parameters.AddWithValue("@nhfs", txtNHFS.Text);
                cmd.Parameters.AddWithValue("@oded", txtOded.Text);
                cmd.Parameters.AddWithValue("@driv", txtDriv.Text);
                cmd.Parameters.AddWithValue("@dome", txtDome.Text);
                cmd.Parameters.AddWithValue("@housU", this.txtHousU.Text);
                cmd.Parameters.AddWithValue("@staffM", this.txtStaffM.Text);
                cmd.Parameters.AddWithValue("@thrift", this.txtThrift.Text);
                cmd.Parameters.AddWithValue("@mon", cmbMon.Text);
                cmd.Parameters.AddWithValue("@otherP", this.txtOtherPay.Text);
                cmd.Parameters.AddWithValue("@photo", this.textBox1.Text);
                cmd.Parameters.AddWithValue("@BrowsePic", this.button1.Text);

                cmd.Connection = con;
                try
                {
                    int k = cmd.ExecuteNonQuery();
                    MessageBox.Show("Deleted...");
                    textBox1.Text = "";
              
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Not Deleted:\n" + ex.Message);
                }
                finally
                {
                    con.Close();
                }

            }
        }

        private void DisplayData()
        {

        }
      //  Staff Parameter
        //private void StaffParameter()
        //{
        //    //cmd.Parameters.AddWithValue("@eid", txteid.Text);
        //    cmd.Parameters.AddWithValue("@yr", cmbYr.Text);
        //    cmd.Parameters.AddWithValue("@dat", datAd.Text);
        //    cmd.Parameters.AddWithValue("@datead", datEmp.Text);
        //    cmd.Parameters.AddWithValue("@datemod", DatMod.Text);
        //    cmd.Parameters.AddWithValue("@staf", txtStaf.Text);
        //    cmd.Parameters.AddWithValue("@adrs", txtAdrs.Text);
        //    cmd.Parameters.AddWithValue("@coy", txtCoy.Text);
        //    cmd.Parameters.AddWithValue("@dpt", cmbDpt.Text);
        //    cmd.Parameters.AddWithValue("@loc", cmbLoc.Text);
        //    cmd.Parameters.AddWithValue("@grd", CmbGrd.Text);
        //    cmd.Parameters.AddWithValue("@accno", TxtAccno.Text);
        //    cmd.Parameters.AddWithValue("@email", txtemail.Text);
        //   // cmd.Parameters.AddWithValue("@picstaffpix", bt);
        //    cmd.Parameters.AddWithValue("@bank", cmbBank.Text);
        //    cmd.Parameters.AddWithValue("@penadmin", cmbPenAdmin.Text);
        //    cmd.Parameters.AddWithValue("@status", cmbStatus.Text);
        //    cmd.Parameters.AddWithValue("@pennum", txtPenNum.Text);
        //    cmd.Parameters.AddWithValue("@bsal", txtBSal.Text);
        //    cmd.Parameters.AddWithValue("@dres", txtDres.Text);
        //    cmd.Parameters.AddWithValue("@Nhis", txtNhis.Text);
        //    cmd.Parameters.AddWithValue("@educ", txtEduc.Text);
        //    cmd.Parameters.AddWithValue("@furn", txtFurn.Text);
        //    cmd.Parameters.AddWithValue("@harz", txtHarz.Text);
        //    cmd.Parameters.AddWithValue("@tran", txtTran.Text);
        //    cmd.Parameters.AddWithValue("@hous", txtHous.Text);
        //    cmd.Parameters.AddWithValue("@lunc", txtLunc.Text);
        //    cmd.Parameters.AddWithValue("@uti", txtUti.Text);
        //    cmd.Parameters.AddWithValue("@housM", txtHousM.Text);
        //    cmd.Parameters.AddWithValue("@risk", txtRisk.Text);
        //    cmd.Parameters.AddWithValue("@veh", txtVeh.Text);
        //    cmd.Parameters.AddWithValue("@pfs", txtPfS.Text);
        //    cmd.Parameters.AddWithValue("@nhf", txtNHF.Text);
        //    cmd.Parameters.AddWithValue("@nhfs", txtNHFS.Text);
        //    cmd.Parameters.AddWithValue("@oded", txtOded.Text);
        //    cmd.Parameters.AddWithValue("@pens", txtPens.Text);
        //    cmd.Parameters.AddWithValue("@paye", this.txtPAYE.Text);
        //    cmd.Parameters.AddWithValue("@tded", txtTDed.Text);
        //    cmd.Parameters.AddWithValue("@driv", txtDriv.Text);
        //    cmd.Parameters.AddWithValue("@dome", txtDome.Text);
        //    cmd.Parameters.AddWithValue("@tpay", txtTPay.Text);
        //    cmd.Parameters.AddWithValue("@npay", txtNPay.Text);
        //    cmd.Parameters.AddWithValue("@housU", this.txtHousU.Text);
        //    cmd.Parameters.AddWithValue("@staffM", this.txtStaffM.Text);
        //    cmd.Parameters.AddWithValue("@thrift", this.txtThrift.Text);
        //    cmd.Parameters.AddWithValue("@mon", cmbMon.Text);
        //    cmd.Parameters.AddWithValue("@otherP", this.txtOtherPay.Text);
        //    cmd.Parameters.AddWithValue("@photo", this.textBox1.Text);
        //    cmd.Parameters.AddWithValue("@BrowsePic", this.button1.Text);

        //}

        // Clear Data  
        private void ClearData()
        {
            txteid.Text = "FHA136";//1
            cmbYr.Text = DateTime.Now.Year.ToString();
            //DateTime.Now.ToShortDateString()
           // DateTime date = new DateTime(YourDateTime.Now.Year, YourDateTime.Now.Month, YourDateTime.Now.Day, 0, 0, 0, 0);
           // DateTime date2 = Convert.ToDateTime(dateString,System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);
            datAd.Text = DateTime.Now.ToString("dd/MM/yyyy");
            datEmp.Text = DateTime.Now.ToString("dd/MM/yyyy");
            DatMod.Text = DateTime.Now.ToString("dd/MM/yyyy");
            txtStaf.Text = "Akintomide Ayodele";
            txtAdrs.Text = "39 Durban Street, Wuse II, Abuja";
            txtCoy.Text = "FHA Homes Ltd";
            cmbDpt.Text = "Operations";
            cmbLoc.Text = "Abuja";
            CmbGrd.Text = "Banking Officer";
            TxtAccno.Text = "11234567";
            txtemail.Text = "info@fhamortgage.gov.ng";
          //  picStafPix.Image="";
           // bt
            // this.picStafPix.Image= Properties.Resources.DefaultPicture;
            // this.picStafPix.Image = Properties.Resources.Culture;
            cmbBank.Text = "United Bank of Africa";
            cmbPenAdmin.Text = "Crusader";
            cmbStatus.Text = "staff";
            txtPenNum.Text = "pen1234";
            txtBSal.Text = "20000";
            txtDres.Text = "20000";
            txtNhis.Text = "10000";
            txtEduc.Text = "10000";
            txtFurn.Text = "25000";
            txtHarz.Text = "20000";
            txtTran.Text = "15000";
            txtHous.Text = "30000";
            txtLunc.Text = "10000";
            txtUti.Text = "10000";
            txtHousM.Text = "10000";
            txtRisk.Text = "20000";
            txtVeh.Text = "10000";
            txtPfS.Text = "10000";
            txtNHF.Text = "10000";
            txtNHFS.Text = "10000";
            txtOded.Text = "10000";
           txtDriv.Text = "10000";
            txtDome.Text = "20000";
            txtHousU.Text = "10000";
            txtStaffM.Text = "20000";
            txtThrift.Text = "20000";
           // cmbMon.Text = DateTime.Now.Month.ToString();
            cmbMon.Text = DateTime.Now.ToString("MMMM");
           //txtOtherPay.Text = "0";
            this.txtOtherPay.Text = "15000";
          //  picStafPix.ImageLocation = textBox1.Text;
            textBox1.Text = "";
            button1.Text = "";
            SN = 0;
            
        }


        //New Record  
        private void New_Rec()
        {

            txteid.Text = "";//1
            cmbYr.Text = DateTime.Now.Year.ToString();
            //DateTime.Now.ToShortDateString()
            // DateTime date = new DateTime(YourDateTime.Now.Year, YourDateTime.Now.Month, YourDateTime.Now.Day, 0, 0, 0, 0);
            // DateTime date2 = Convert.ToDateTime(dateString,System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);
            //datAd.Text = DateTime.Now.ToShortDateString();
            datAd.Text = DateTime.Now.ToString("dd/MM/yyyy"); 
            datEmp.Text = DateTime.Now.ToString("dd/MM/yyyy");
            DatMod.Text = DateTime.Now.ToString("dd/MM/yyyy");
            txtStaf.Text = "";
            txtAdrs.Text = "39 Durban Street, Wuse II, Abuja";
            txtCoy.Text = "FHA Homes Ltd";
            cmbDpt.Text = "Operations";
            cmbLoc.Text = "Abuja";
            CmbGrd.Text = "Banking Officer";
            TxtAccno.Text = "11234567";
            txtemail.Text = "info@fhamortgage.gov.ng";
            //  picStafPix.Image="";
            // bt
            // this.picStafPix.Image= Properties.Resources.DefaultPicture;
            // this.picStafPix.Image = Properties.Resources.Culture;
            cmbBank.Text = "United Bank of Africa";
            cmbPenAdmin.Text = "Crusader";
            cmbStatus.Text = "staff";
            txtPenNum.Text = "pen1234";
            txtBSal.Text = "0";
            txtDres.Text = "0";
            txtNhis.Text = "0";
            txtEduc.Text = "0";
            txtFurn.Text = "0";
            txtHarz.Text = "0";
            txtTran.Text = "0";
            txtHous.Text = "";
            txtLunc.Text = "0";
            txtUti.Text = "0";
            txtHousM.Text = "0";
            txtRisk.Text = "0";
            txtVeh.Text = "0";
            txtPfS.Text = "0";
            txtNHF.Text = "0";
            txtNHFS.Text = "0";
            txtOded.Text = "0";
            txtDriv.Text = "0";
            txtDome.Text = "0";
           // txtTPay.Text = "0";
            //txtNPay.Text = "0";
            txtHousU.Text = "0";
            txtStaffM.Text = "0";
            txtThrift.Text = "0";
            // cmbMon.Text = DateTime.Now.Month.ToString();
            cmbMon.Text = DateTime.Now.ToString("MMMM");
            //txtOtherPay.Text = "0";
            this.txtOtherPay.Text = "0";
            //  picStafPix.ImageLocation = textBox1.Text;
            textBox1.Text = "";
            button1.Text = "";
            SN = 0;
            
        }

        private void Add_Employee_Load(object sender, EventArgs e)
        {
            {

                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                string sqlLoc = "SELECT * FROM Location";
                var lAdapter = new SqlDataAdapter(sqlLoc, con);
                var lset = new DataSet();
                lAdapter.TableMappings.Add("Table", "Location");
                lAdapter.Fill(lset);
                this.dviewmanager = lset.DefaultViewManager;
                try
                {

                    for (int i = 0; i <= lset.Tables[0].Rows.Count - 1; i++)
                    {
                        this.cmbLoc.Items.Add(lset.Tables[0].Rows[i]["Location"].ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Not successful:\n" + ex.Message);
                }
                this.cmbMon.Items.Add("January");
                this.cmbMon.Items.Add("February");
                this.cmbMon.Items.Add("March");
                this.cmbMon.Items.Add("April");
                this.cmbMon.Items.Add("May");
                this.cmbMon.Items.Add("June");
                this.cmbMon.Items.Add("July");
                this.cmbMon.Items.Add("August");
                this.cmbMon.Items.Add("September");
                this.cmbMon.Items.Add("October");
                this.cmbMon.Items.Add("November");
                this.cmbMon.Items.Add("December");

            }
        }

        protected void FillBank()
        {

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string sqlStr = "SELECT * FROM BANK";
            var dAdapter = new SqlDataAdapter(sqlStr, con);
            var dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "Bank");
            dAdapter.Fill(dset);
            this.dviewmanager = dset.DefaultViewManager;
            try
            {

                for (int i = 0; i <= dset.Tables[0].Rows.Count - 1; i++)
                {
                    this.cmbBank.Items.Add(dset.Tables[0].Rows[i]["Bank"].ToString());

                }


            }
            catch (Exception ex)
            {
                //Exception Message
                MessageBox.Show("Not successful:\n" + ex.Message);
            }
        }
        protected void FillDpt()
        {

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string sqlStr = "SELECT * FROM Dpt";
            var dAdapter = new SqlDataAdapter(sqlStr, con);
            var dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "Dpt");
            dAdapter.Fill(dset);
            this.dviewmanager = dset.DefaultViewManager;
            try
            {

                for (int i = 0; i <= dset.Tables[0].Rows.Count - 1; i++)
                {
                    this.cmbDpt.Items.Add(dset.Tables[0].Rows[i]["Dpt"].ToString());

                }


            }
            catch (Exception ex)
            {
                //Exception Message
                MessageBox.Show("Not successful:\n" + ex.Message);
            }
        }
        protected void FillYear()
        {

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string sqlStr = "SELECT * FROM Year";
            var dAdapter = new SqlDataAdapter(sqlStr, con);
            var dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "Year");
            dAdapter.Fill(dset);
            this.dviewmanager = dset.DefaultViewManager;
            try
            {

                for (int i = 0; i <= dset.Tables[0].Rows.Count - 1; i++)
                {
                    this.cmbYr.Items.Add(dset.Tables[0].Rows[i]["Year"].ToString());

                }


            }
            catch (Exception ex)
            {
                //Exception Message
                MessageBox.Show("Not successful:\n" + ex.Message);
            }
        }
        protected void FillGrade()
        {

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string sqlStr = "SELECT * FROM Grade";
            var dAdapter = new SqlDataAdapter(sqlStr, con);
            var dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "Grade");
            dAdapter.Fill(dset);
            this.dviewmanager = dset.DefaultViewManager;
            try
            {

                for (int i = 0; i <= dset.Tables[0].Rows.Count - 1; i++)
                {
                    this.CmbGrd.Items.Add(dset.Tables[0].Rows[i]["Grade"].ToString());

                }


            }
            catch (Exception ex)
            {
                //Exception Message
                MessageBox.Show("Not successful:\n" + ex.Message);
            }
        }
        protected void FillStatus()
        {

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string sqlStr = "SELECT * FROM Status";
            var dAdapter = new SqlDataAdapter(sqlStr, con);
            var dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "Status");
            dAdapter.Fill(dset);
            this.dviewmanager = dset.DefaultViewManager;
            try
            {

                for (int i = 0; i <= dset.Tables[0].Rows.Count - 1; i++)
                {
                    this.cmbStatus.Items.Add(dset.Tables[0].Rows[i]["Status"].ToString());


                }


            }
            catch (Exception ex)
            {
                //Exception Message
                MessageBox.Show("Not successful:\n" + ex.Message);
            }
        }
        protected void FillPenAdmin()
        {

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            string sqlStr = "SELECT * FROM PenAdmin";
            var dAdapter = new SqlDataAdapter(sqlStr, con);
            var dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "PenAdmin");
            dAdapter.Fill(dset);
            this.dviewmanager = dset.DefaultViewManager;
            try
            {

                for (int i = 0; i <= dset.Tables[0].Rows.Count - 1; i++)
                {
                    this.cmbPenAdmin.Items.Add(dset.Tables[0].Rows[i]["PenAdmin"].ToString());


                }


            }
            catch (Exception ex)
            {
                //Exception Message
            }
        }


        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void label14_Click(object sender, EventArgs e)
        {

        }

        private void frmTpay_Enter(object sender, EventArgs e)
        {

        }

        private void txtHousU_TextChanged(object sender, EventArgs e)
        {

        }

        private void label33_Click(object sender, EventArgs e)
        {

        }

        private void txtStaffM_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtPAYE_TextChanged(object sender, EventArgs e)
        {

        }

        private void datEmp_ValueChanged(object sender, EventArgs e)
        {
            //// Set title bar to selected date.
            //DateTime result = dateTimePicker1.Value;
            //this.Text = result.ToString();
        }

        

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

      

        private void txtTran_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //SaveImage();
        }

        private void btnNew_Click(object sender, EventArgs e)
        {
            New_Rec();
        }

        private void groupBox1_Enter_1(object sender, EventArgs e)
        {

        }


        

        
       
}
}

1 Ответов

Рейтинг:
12

Bryian Tan

Я думаю, что обзор-это зарезервированное ключевое слово. Заверните его в квадратную скобку .[обзор], чтобы избежать этого.


Arham Anees

подтвердил это, это Заповедное слово

Aydotcom

Привет, Архам, я благодарен тебе. Предложение работает