//load du lieu vao combb
        public void loaddlcbb(BANHANG f)
        {
            var sql = data.database().MATHANGs.ToList();

            f.cbb_tenmh.DataSource         = sql;
            f.cbb_tenmh.DisplayMember      = "TENMH";
            f.cbb_tenmh.ValueMember        = "MAMH";
            f.cbb_tenmh.AutoCompleteMode   = AutoCompleteMode.Suggest;
            f.cbb_tenmh.AutoCompleteSource = AutoCompleteSource.ListItems;
        }
 //tinh tien thua cho khach
 public void tienthua(BANHANG f, string tien)
 {
     if (tien == "")
     {
         f.lb_tienthua.Text = "0";
     }
     else
     {
         f.lb_tienthua.Text = Convert.ToString((tongtrigia - khuyenmai) - int.Parse(f.txt_khachtra.Text));
     }
 }
        //xoa mat hang da chon
        public void xoa(BANHANG f)
        {
            int    donghientai = f.gv_banhang.FocusedRowHandle;
            string mamh        = f.gv_banhang.GetRowCellValue(donghientai, "MAMH").ToString();
            var    sql         = data.database().CTHDs.SingleOrDefault(a => a.SOHD == sohd && a.MAMH == mamh);

            tongtrigia = tongtrigia - (double)(sql.DONGIA * sql.SOLUONGMUA);
            data.database().CTHDs.DeleteOnSubmit(sql);
            data.database().SubmitChanges();
            loaddulieu(f);
            f.lb_tongdongia.Text = Convert.ToString(tongtrigia);
        }
        //dua ra ten khach hang khi dua vao sdt
        public void truyvantenkh(BANHANG f, string sdt)
        {
            int ktr           = 0;
            var sql_khachhang = data.database().KHACHHANGs.ToList();

            foreach (var item in sql_khachhang)
            {
                if (item.DIENTHOAI_KH == sdt)
                {
                    f.txt_tenkh.Text = item.TENKH;
                    ktr = 1;
                }
            }
            if (ktr == 0)
            {
                f.txt_tenkh.Text = "";
            }
        }
        public void insertcthd_hd(BANHANG f, string tenmh, string sl)
        {
            CTHD C = new CTHD();

            C.SOHD = sohd;
            MATHANG MH = data.database().MATHANGs.SingleOrDefault(a => a.TENMH == tenmh);

            if (MH != null)
            {
                mamathang = MH.MAMH;
                C.MAMH    = MH.MAMH;
                C.DONGIA  = MH.GIABAN;
            }
            C.SOLUONGMUA = int.Parse(sl);
            C.THUEVAT    = 10;

            //cap nhat tong tri gia
            tongtrigia += (double)((int.Parse(sl) * C.DONGIA));
            khuyenmai  += (double)(((int.Parse(sl) * C.DONGIA)) * MH.KHUYENMAI / 100);
            data.database().CTHDs.InsertOnSubmit(C);
            data.database().SubmitChanges();
            int kt = 0;

            //load dữ liêu mặt hàng được chọn
            if (sl == "")
            {
                XtraMessageBox.Show("Bạn Chưa Chọn Số Lượng Sản Phẩm!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                kt = 1;
            }
            if (kt == 0)
            {
                loaddulieu(f);
                f.lb_tongdongia.Text = Convert.ToString(tongtrigia);
                f.lb_khuyenmai.Text  = Convert.ToString(khuyenmai);
                f.lb_tiencantra.Text = Convert.ToString(tongtrigia - khuyenmai);
            }
        }
        //LOAD DU LIEU DANH SACH CHON KHI CHON HANG HOA
        public void loaddulieu(BANHANG f)
        {
            var sql = data.database().PROC_BANHANG().Where(a => a.SOHD == sohd).ToList();

            f.gctrl_banhang.DataSource = sql;
        }
示例#7
0
        //mỡ form bán hàng
        private void tileItem4_ItemClick(object sender, DevExpress.XtraEditors.TileItemEventArgs e)
        {
            BANHANG f = new BANHANG();

            f.Show();
        }