Ejemplo n.º 1
0
 // insert loai cong
 #region them loai cong
 public static bool InsertLoaicong(DMLoaicong loaicong)
 {
     try
     {
         DataTable      dt = new DataTable("DMLoaiCong");
         SqlDataAdapter da = new SqlDataAdapter();
         SqlCommand     cm = new SqlCommand();
         cm.Connection  = DA.Ketnoi.Cmb();
         cm.CommandType = CommandType.Text;
         cm.CommandText = @"insert into DMloaicong(maloai,tenloai,heso) values (@maloai,@tenloai,@heso)";
         cm.Parameters.Add("@maloai", SqlDbType.NVarChar, 10).Value   = loaicong.Maloai;
         cm.Parameters.Add("@tenloai", SqlDbType.NVarChar, 100).Value = loaicong.Tenloai;
         cm.Parameters.Add("@heso", SqlDbType.Float, 50).Value        = loaicong.Heso;
         da.SelectCommand = cm;
         da.Fill(dt);
         return(true);
     }
     catch
     {
         return(false);
     }
     //string s= "Insert into DMloaicong values ('"+loaicong.Maloai+"','"+loaicong.Tenloai+"',"+loaicong.Heso+")";
     //string sql = string.Format(s);
     //return DA.Ketnoi.ExcuteNonQuery(sql);
 }
Ejemplo n.º 2
0
        public static string _sua(DMLoaicong lc, string maloai)
        {
            string s   = "update DMloaicong set maloai='" + lc.Maloai + "', tenloai=N'" + lc.Tenloai + "', heso='" + lc.Heso + "' where maloai='" + maloai + "'";
            string sql = string.Format(s);

            return(DA.Ketnoi.ExcuteNonQuery(sql));
        }
Ejemplo n.º 3
0
        private void sua()
        {
            DMLoaicong lc = new DMLoaicong();

            lc.Maloai  = txtMaloaicong.Text;
            lc.Tenloai = txtTenloaicong.Text;
            lc.Heso    = txtHeso.Text;
            frmSualoaicong frm = new frmSualoaicong(lc);

            frm.reload = new frmSualoaicong.Reload(Loadtoanbothongtin);
            frm.Show();
        }
Ejemplo n.º 4
0
        // select loai cong
        #region select loai cong
        public static List <DTO.DMLoaicong> selectLoaicong()
        {
            List <DTO.DMLoaicong> lc = new List <DMLoaicong>();
            DataTable             tb = new DataTable();

            tb = DA.Ketnoi.ExcecuteQuery("select * from DMLoaicong");
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                DMLoaicong lc1 = new DMLoaicong();
                lc1.Maloai  = tb.Rows[i]["maloai"].ToString();
                lc1.Tenloai = tb.Rows[i]["tenloai"].ToString();
                lc1.Heso    = tb.Rows[i]["heso"].ToString();
                lc.Add(lc1);
            }
            return(lc);
        }
Ejemplo n.º 5
0
 public void Capnhat()
 {
     if (kiemtraNhap())
     {
         DMLoaicong loaicong = new DMLoaicong();
         loaicong.Maloai  = txtMaloaicong.Text;
         loaicong.Tenloai = txtTenloaicong.Text;
         loaicong.Heso    = txtHesoluong.Text;
         if (BUS.BUS_Loaicong._sua(loaicong, lc.Maloai) == "true")
         {
             MessageBox.Show("Sửa thành công loại công có mã " + txtMaloaicong.Text + "", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             reload();
             this.Close();
         }
     }
 }
Ejemplo n.º 6
0
 // sua loai cong
 public static string _sua(DMLoaicong lc, string maloai)
 {
     return(DAO.DAO_Loaicong._sua(lc, maloai));
 }