public void luuCTHD(HDNH_DTO hd)
 {
     sql = "INSERT INTO CTHDNHAP VALUES (@mahd, @mahh, @sl, @thanhtien)";
     conn.Open();
     cmd = new SqlCommand(sql, conn);
     cmd.Parameters.AddWithValue("@mahd", hd.Mahd);
     cmd.Parameters.AddWithValue("@mahh", hd.Mahh);
     cmd.Parameters.AddWithValue("@sl", hd.SL);
     cmd.Parameters.AddWithValue("@thanhtien", hd.Thanhtien);
     cmd.ExecuteNonQuery();
     conn.Close();
 }
Exemple #2
0
        private void formHoaDonNhapHang_Load(object sender, EventArgs e)
        {
            AutoCompleteStringCollection auto = new AutoCompleteStringCollection();

            dto  = new HDNH_DTO();
            test = bus.auto(dto);
            foreach (var giatri in test)
            {
                auto.Add(giatri.Ten);
            }
            txtTenHH.AutoCompleteCustomSource = auto;
        }
 public void luuHD(HDNH_DTO hd)
 {
     sql = "INSERT INTO HDNHAPHH VALUES(@mahd, @ngay, @manv, @tongtien)";
     conn.Open();
     cmd = new SqlCommand(sql, conn);
     cmd.Parameters.AddWithValue("@mahd", hd.Mahd);
     cmd.Parameters.AddWithValue("@ngay", hd.NgayNhap);
     cmd.Parameters.AddWithValue("@manv", hd.Manv);
     cmd.Parameters.AddWithValue("@tongtien", hd.TongTien);
     cmd.ExecuteNonQuery();
     conn.Close();
 }
        public List <HDNH_DTO> autoComplete(HDNH_DTO hd)
        {
            List <HDNH_DTO> giatri = new List <HDNH_DTO>();

            sql = "SELECT TENHH FROM HANGHOA";
            conn.Open();
            cmd = new SqlCommand(sql, conn);
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                var tensp = new HDNH_DTO();
                tensp.Ten = dr[0].ToString();
                giatri.Add(tensp);
            }
            conn.Close();
            return(giatri);
        }
        public List <HDNH_DTO> timGiaVaMa(HDNH_DTO hd)
        {
            List <HDNH_DTO> giatri = new List <HDNH_DTO>();

            sql = "SELECT DONGIA, MAHH FROM HANGHOA WHERE TENHH = N'" + hd.Ten + "'";
            conn.Open();
            cmd = new SqlCommand(sql, conn);
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                hd.DonGia = int.Parse(dr[0].ToString());
                hd.Mahh   = int.Parse(dr[1].ToString());
                giatri.Add(hd);
            }
            conn.Close();
            return(giatri);
        }
Exemple #6
0
 private void txtTenHH_TextChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtTenHH.Text))
     {
         dto = new HDNH_DTO(txtTenHH.Text);
         List <HDNH_DTO> test = new List <HDNH_DTO>();
         test = bus.timGiaVaMa(dto);
         foreach (var giatri in test)
         {
             txtDonGia.Text = giatri.DonGia.ToString();
             ma             = giatri.Mahh.ToString();
         }
     }
     else
     {
         txtDonGia.Text = "0";
     }
 }
Exemple #7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string   format = "yyyy-MM-dd";
            DateTime now    = DateTime.Now;
            string   date   = now.ToString(format);

            if (!string.IsNullOrWhiteSpace(txtMaHD.Text))
            {
                try
                {
                    dto = new HDNH_DTO(txtMaHD.Text, date, 1, int.Parse(txtTong.Text));
                    bus.luuHD(dto);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                //
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    try
                    {
                        dto = new HDNH_DTO(txtMaHD.Text, int.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()), int.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString()), int.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString()));
                        bus.luuCTHD(dto);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                MessageBox.Show("Thêm thành công");
                txtMaHD.Text  = string.Empty;
                txtTenHH.Text = string.Empty;
            }
            else
            {
                MessageBox.Show("Vui lòng nhập mã");
            }
        }
Exemple #8
0
 public List <HDNH_DTO> auto(HDNH_DTO hd)
 {
     return(dao.autoComplete(hd));
 }
Exemple #9
0
 public List <HDNH_DTO> timGiaVaMa(HDNH_DTO hd)
 {
     return(dao.timGiaVaMa(hd));
 }
Exemple #10
0
 public void luuCTHD(HDNH_DTO hd)
 {
     dao.luuCTHD(hd);
 }