示例#1
0
        public bool Delete(Entities.TheVip thevip)
        {
            bool trave = false;

            try
            {
                string sql = new Common.Constants.Sql().deleteTheVip;
                conn = new Connection();
                Constants.TheVip tv = new Constants.TheVip();
                cn  = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value = thevip.MaThe.ToUpper();
                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    trave = true;
                }
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                trave = false;
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(trave);
        }
示例#2
0
 public Entities.TheVip[] Select(Entities.TheVip thevip)
 {
     Entities.TheVip[] arrC = null;
     try
     {
         string           sql = new Common.Constants.Sql().selectTheVipAll;
         Constants.TheVip tv  = new Constants.TheVip();
         conn = new Connection();
         cn   = conn.openConnection();
         cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
         dr  = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.TheVip tao = new Entities.TheVip();
             tao.MaKhachHang  = dr[tv.MaKhachHang].ToString().ToUpper();
             tao.MaThe        = dr[tv.MaThe].ToString().ToUpper();
             tao.GiaTriThe    = dr[tv.GiaTriThe].ToString();
             tao.GiaTriConLai = dr[tv.GiaTriConLai].ToString();
             tao.GhiChu       = dr[tv.GhiChu].ToString();
             tao.SoDiem       = dr[tv.SoDiem].ToString();
             tao.Deleted      = (bool)dr[tv.Deleted];
             arr.Add(tao);
         }
         //int n = arr.Count;
         //if (n == 0) { arrC = null; }
         //arrC = new Entities.TheVip[n];
         //for (int i = 0; i < n; i++)
         //{
         //    arrC[i] = (Entities.TheVip)arr[i];
         //}
         if (arr.Count > 0)
         {
             arrC = (Entities.TheVip[])arr.ToArray(typeof(Entities.TheVip));
         }
         else
         {
             return(new Entities.TheVip[0]);
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); arrC = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return(arrC);
 }
示例#3
0
        public bool Insert(Entities.TheVip thevip)
        {
            bool trave = false;

            try
            {
                string sql = new Common.Constants.Sql().insertTheVip;
                conn = new Connection();
                Constants.TheVip tv = new Constants.TheVip();
                cn  = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
                cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value       = thevip.MaThe.ToUpper();
                cmd.Parameters.Add(tv.GiaTriThe, SqlDbType.Float).Value         = thevip.GiaTriThe;
                cmd.Parameters.Add(tv.GiaTriConLai, SqlDbType.Float).Value      = thevip.GiaTriConLai;
                cmd.Parameters.Add(tv.GhiChu, SqlDbType.VarChar, 100).Value     = thevip.GhiChu;
                cmd.Parameters.Add(tv.SoDiem, SqlDbType.VarChar, 100).Value     = thevip.SoDiem;

                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    trave = true;
                }
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                trave = false;
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(trave);
        }
示例#4
0
        /// <summary>
        /// nút thêm
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsslthem_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            try
            {
                if (KiemTra() == true)
                {
                    //CheckConflictInsert();
                    txtSochungtu.Text = ProID("HDBanHang");
                    kt = true;
                    if (kt == true)
                    {
                        cl = new Server_Client.Client();
                        this.Client1 = cl.Connect(Luu.IP, Luu.Ports);
                        string date = "";
                        try
                        {
                            date = new Common.Utilities().MyDateConversion(mskngaychungtu.Text);
                        }
                        catch
                        {
                            MessageBox.Show("Bạn nhập sai định dạng ngày tháng", "Hệ thống cảnh báo");
                            mskngaychungtu.Focus();
                            return;
                        }
                        string khachtra = "0";
                        if (txtkhachtra.Text == "")
                            khachtra = "0";
                        else
                            khachtra = txtkhachtra.Text;
                        if (Convert.ToDouble(khachtra) < (Convert.ToDouble(txtTongtien.Text) - Convert.ToDouble(txtGTTheVip.Text) - double.Parse(txtGTTheGT.Text)))
                        {
                            lbloi.Text = "Khách trả không thể nhỏ hơn Tổng tiền";
                            return;
                        }
                        Entities.HDBanHang pt = new Entities.HDBanHang();
                        string makho = LayMaKho(cbbkhohang.Text);
                        double ttn = 0;
                        Entities.TheVip tv1 = null;
                        Entities.TheGiamGia tgg1 = null;
                        // The Vip
                        if (Convert.ToDouble(txtTongtien.Text) < Convert.ToDouble(txtGTTheVip.Text))
                        {
                            ttn = Convert.ToDouble(txtGTTheVip.Text) - Convert.ToDouble(txtTongtien.Text);
                            tv1 = new Entities.TheVip("", txtMaTheVip.Text, "", ttn.ToString(), "", "", false);
                        }
                        else
                        {
                            ttn = Convert.ToDouble(txtTongtien.Text) - Convert.ToDouble(txtGTTheVip.Text);
                            tv1 = new Entities.TheVip("", txtMaTheVip.Text, "", "0", "", "", false);
                            // The Gia Tri.
                            if (Convert.ToDouble(txtTongtien.Text) - Convert.ToDouble(txtGTTheVip.Text) < Convert.ToDouble(txtGTTheGT.Text))
                            {
                                ttn = Convert.ToDouble(txtGTTheGT.Text) - (Convert.ToDouble(txtTongtien.Text) - Convert.ToDouble(txtGTTheVip.Text));
                                tgg1 = new Entities.TheGiamGia();
                                tgg1.MaTheGiamGia = txtMaTheGT.Text;
                                tgg1.GiaTriConLai = ttn.ToString();
                            }
                            else
                            {
                                ttn = Convert.ToDouble(txtTongtien.Text) - Convert.ToDouble(txtGTTheVip.Text) - Convert.ToDouble(txtGTTheVip.Text);
                                tgg1 = new TheGiamGia { MaTheGiamGia = txtMaTheGT.Text, GiaTriConLai = "0" };
                            }
                        }

                        chietkhau = (double.Parse(txtGiamgia.Text) + double.Parse(txtChietkhau.Text)).ToString();
                        string ckTongHoaDon = txtPhantramchietkhau.Text;
                        if (string.IsNullOrEmpty(txtPhantramchietkhau.Text))
                            ckTongHoaDon = "0";
                        pt = new HDBanHang("Insert", 0, txtSochungtu.Text, Convert.ToDateTime(date),
                            txtMakhachhang.Text, "0", " ", cbxHinhthucthanhtoan.Text, makho, _datesv, " ",
                            (_currentNhanVien != null) ? _currentNhanVien.MaNhanVien : Common.Utilities.User.NhanVienID, "TT_0001", txtGiamgia.Text, ttn.ToString(), "0",
                            txtGTGT.Text, txtTongtien.Text, true, txtMaTheVip.Text, txtGTTheVip.Text, txtDiengiai.Text, false,
                            Common.Utilities.User.TenDangNhap, txtkhachtra.Text, ckTongHoaDon, txtMaTheGT.Text, txtGTTheGT.Text)
                                 {
                                     ChiTietHDBanHang = CheckDataGridInsert(dtgvsanpham),
                                     ChiTietKhoHangTheoHoaHonNhap = CheckDataGridTruSL(dtgvsanpham),
                                     TheVip = tv1,
                                     TheGiamGia = tgg1
                                 };

                        Clientstrem = cl.SerializeObj(this.Client1, "HDBanHang", pt);

                        bool kt1 = false;
                        kt1 = (bool)cl.DeserializeHepper(Clientstrem, kt1);
                        if (kt1 == true)
                        {
                            //Cập nhật điểm thưởng cho khách hàng
                            if (!string.IsNullOrEmpty(txtMakhachhang.Text))
                            {
                                //Cập nhật điểm thưởng khách hàng thành công
                                bool kq = CapNhatDiemThuongKhachHang(txtMakhachhang.Text, txtTongtien.Text);
                            }
                            else
                            {
                                //Cập nhật điểm thưởng khách hàng thất bại
                            }
                            /////////////////////////////////////
                            khachtra = "0";
                            if (txtkhachtra.Text == "")
                                khachtra = "0";
                            else
                                khachtra = txtkhachtra.Text;

                            if (cbkiemtra.Checked == true)
                            {
                                frmBaoCaorpt bcrpt = new frmBaoCaorpt("HDBanLe", txtSochungtu.Text, double.Parse(txtGiamgia.Text), khachtra, txtdutra.Text, txtKhachPhaiTra.Text, txtGTGT.Text, lbnhanvien.Text, "in", mskngaychungtu.Text, txtGTTheVip.Text, txtGTTheGT.Text, "", txtChietkhau.Text, "", "", "");
                            }

                            GiaVonBanHang(pt.ChiTietHDBanHang);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Thêm thất bại - xin thử lại", "Hệ thống cảnh báo");
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                this.Enabled = true;

            }
        }
示例#5
0
        public void TheVip()
        {
            cl = new Server_Client.Client();

            // gán TCPclient
            this.Client1 = cl.Connect(Luu.IP, Luu.Ports);
            // khởi tạo biến truyền vào với hàm khởi tạo
            Entities.TheVip pt = new Entities.TheVip("Select");
            Clientstrem = cl.SerializeObj(this.Client1, "LayTheVip", pt);
            // đổ mảng đối tượng vào datagripview
            thevip = (Entities.TheVip[])cl.DeserializeHepper1(Clientstrem, thevip);
            if (thevip == null)
                thevip = new Entities.TheVip[0];
        }
示例#6
0
 public Entities.TheVip[] Select(Entities.TheVip thevip)
 {
     Entities.TheVip[] arrC = null;
     try
     {
         string sql = new Common.Constants.Sql().selectTheVipAll;
         Constants.TheVip tv = new Constants.TheVip();
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.TheVip tao = new Entities.TheVip();
             tao.MaKhachHang = dr[tv.MaKhachHang].ToString().ToUpper();
             tao.MaThe = dr[tv.MaThe].ToString().ToUpper();
             tao.GiaTriThe = dr[tv.GiaTriThe].ToString();
             tao.GiaTriConLai = dr[tv.GiaTriConLai].ToString();
             tao.GhiChu = dr[tv.GhiChu].ToString();
             tao.SoDiem = dr[tv.SoDiem].ToString();
             tao.Deleted = (bool)dr[tv.Deleted];
             arr.Add(tao);
         }
         //int n = arr.Count;
         //if (n == 0) { arrC = null; }
         //arrC = new Entities.TheVip[n];
         //for (int i = 0; i < n; i++)
         //{
         //    arrC[i] = (Entities.TheVip)arr[i];
         //}
         if (arr.Count > 0)
         {
             arrC = (Entities.TheVip[])arr.ToArray(typeof(Entities.TheVip));
         }
         else
             return new Entities.TheVip[0];
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); arrC = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return arrC;
 }