//----------------------------------------------------------------
        //THEM, XOA, SUA
        public bool themChiTietHoaDon(ET_ChiTietHoaDon eT_ChiTietHoaDon)
        {
            try
            {
                openDB();
                SqlCommand cmd = HandleCMD.proc("sp_ThemChiTietHoaDon", _con);

                addParameter(cmd, eT_ChiTietHoaDon, strNameParametor);

                if (this.cmdExecuted(cmd))
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
                return(false);
            }
            finally
            {
                closeDB();
            }
            return(false);
        }
        public Boolean CreateChiTietHD()
        {
            List <ET_ChiTietHoaDon> listET = new List <ET_ChiTietHoaDon>();
            Boolean flag = true;

            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                string maSach  = Convert.ToString(dataGridView1.Rows[i].Cells["dgvcbcSach"].Value);
                string maHD    = CreateNewID();
                string soLuong = Convert.ToString(dataGridView1.Rows[i].Cells["dgvtxtSoluong"].Value);
                if (CheckIsDigit(soLuong))
                {
                    ET_ChiTietHoaDon et = new ET_ChiTietHoaDon(maSach, maHD, int.Parse(soLuong));
                    listET.Add(et);
                }
                else
                {
                    flag = false;
                    Console.WriteLine("ERROR: " + "item " + i + " không đúng");
                    MessageBox.Show("Xin lỗi đã xảy ra lỗi trong quá trình thao tác!!!", "Thống báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            if (flag)
            {
                for (int i = 0; i < listET.Count; i++)
                {
                    bus_ChiTietHoaDon.themChiTietHD(listET[i]);
                }
            }
            return(flag);
        }
        //----------------------------------------------------------------
        //HAM PHU
        public void addParameter(SqlCommand cmd, ET_ChiTietHoaDon eT_ChiTietHoaDon, String[] strNameParametor)
        {
            ArrayList list = eT_ChiTietHoaDon.getAllProperties();

            foreach (string item in strNameParametor)
            {
                SqlParameter pt = new SqlParameter(item, list[Array.IndexOf(strNameParametor, item)]);
                cmd.Parameters.Add(pt);
            }
        }
Exemple #4
0
 public bool suaChiTietHD(ET_ChiTietHoaDon et_ChiTietHD)
 {
     return(dal_ChiTietHD.suaChiTietHoaDon(et_ChiTietHD));
 }
Exemple #5
0
 public bool themChiTietHD(ET_ChiTietHoaDon et_ChiTietHD)
 {
     return(dal_ChiTietHD.themChiTietHoaDon(et_ChiTietHD));
 }