public bool modelInfoUpdate(models modelInfo)
        {
            bool          sonuc = false;
            cGenel        gnl   = new cGenel();
            SqlConnection con   = new SqlConnection(gnl.conString);
            SqlCommand    cmd   = new SqlCommand("update MODELS set  MODELKODU=@MODELKODU, MODELADI=@MODELADI where MODELNO=@MODELNO", con);

            cmd.Parameters.Add("@MODELKODU", SqlDbType.NVarChar).Value = modelInfo._MODELKODU;
            cmd.Parameters.Add("@MODELADI", SqlDbType.NVarChar).Value  = modelInfo._MODELADI;
            cmd.Parameters.Add("@MODELNO", SqlDbType.NVarChar).Value   = modelInfo._MODELNO;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                sonuc = Convert.ToBoolean(cmd.ExecuteNonQuery());
            }
            catch (Exception ex)
            {
                mesajlar.hata(ex, "");
            }
            finally
            {
                con.Close();
                con.Dispose();
            }


            return(sonuc);
        }
        private void dataGridModels_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            models model = new models();

            model._MODELNO    = dataGridModels.SelectedCells[0].Value.ToString();
            txtModelNo.Text   = model._MODELNO;
            txtModelKodu.Text = model.speckInfoSearch(model._MODELNO)._MODELKODU;
            txtModelAdi.Text  = model.speckInfoSearch(model._MODELNO)._MODELADI;
        }
        public void formYukle()
        {
            models model = new models();

            dataGridModels.AutoGenerateColumns = true;
            var list = model.modelList();
            var lst  = (from s in list
                        select new { MODELADI = s._MODELADI, KODU = s._MODELKODU, NO = s._MODELNO }).ToList();

            dataGridModels.DataSource = lst;
        }
        private void btnBarkodSearch_Click(object sender, EventArgs e)
        {
            models model = new models();

            model._MODELNO = txtModelNo.Text.Trim();


            if (model.speckInfoSearch(model._MODELNO)._MODELNO != null)
            {
                txtModelNo.Text   = model.speckInfoSearch(model._MODELNO)._MODELNO;
                txtModelKodu.Text = model.speckInfoSearch(model._MODELNO)._MODELKODU;
                txtModelAdi.Text  = model.speckInfoSearch(model._MODELNO)._MODELADI;
            }
            else
            {
                cGenel.genelUyari("Model bulunamadı!", false);
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            models model = new models();


            model._MODELNO = model.speckInfoSearch(txtModelNo.Text)._MODELNO;

            bool result = model.modelInfoDelete(model._MODELNO);

            if (result)
            {
                cGenel.genelUyari("Model silme başarılı!", false);
                formYukle();
            }
            else
            {
                cGenel.genelUyari("Model silme başarısız!", false);
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            models model = new models();

            model._MODELADI  = txtModelAdi.Text;
            model._MODELKODU = txtModelKodu.Text;
            model._MODELNO   = txtModelNo.Text;


            bool result = model.modelInfoUpdate(model);

            if (result)
            {
                cGenel.genelUyari("Model güncelleme başarılı!", false);
                formYukle();
            }
            else
            {
                cGenel.genelUyari("Model güncelleme başarısız!", false);
            }
        }
        public List <models> modelList()
        {
            List <models> list = new List <models>();
            models        info;
            cGenel        gnl = new cGenel();
            SqlConnection con = new SqlConnection(gnl.conString);
            SqlCommand    cmd = new SqlCommand("select * from MODELS ", con);
            SqlDataReader dr  = null;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    info            = new models();
                    info._MODELNO   = Convert.ToString(dr["MODELNO"]);
                    info._MODELKODU = Convert.ToString(dr["MODELKODU"]);
                    info._MODELADI  = Convert.ToString(dr["MODELADI"]);
                    list.Add(info);
                }
            }
            catch (Exception ex)
            {
                mesajlar.hata(ex, "");
            }
            finally
            {
                con.Close();
                con.Dispose();
            }


            return(list);
        }
        public models speckInfoSearch(string modelNo)
        {
            models        info = new models();
            cGenel        gnl  = new cGenel();
            SqlConnection con  = new SqlConnection(gnl.conString);
            SqlCommand    cmd  = new SqlCommand("select * from MODELS where MODELNO=@MODELNO", con);

            cmd.Parameters.Add("@MODELNO", SqlDbType.NVarChar).Value = modelNo;
            SqlDataReader dr = null;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    info._MODELNO   = Convert.ToString(dr["MODELNO"]);
                    info._MODELKODU = Convert.ToString(dr["MODELKODU"]);
                    info._MODELADI  = Convert.ToString(dr["MODELADI"]);
                }
            }
            catch (Exception ex)
            {
                mesajlar.hata(ex, "");
            }
            finally
            {
                con.Close();
                con.Dispose();
            }


            return(info);
        }