Пример #1
0
        private void buttonYes_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (dataGridViewThamSo.Rows[Index].Cells["ColTenThamSo"].Value == null)
            {
                MessageBox.Show("Tên tham số không được để trống");
                dataGridViewThamSo.CurrentCell = dataGridViewThamSo.Rows[Index].Cells["ColTenThamSo"];
                dataGridViewThamSo.BeginEdit(true);
                flag = false;
            }
            else if (dataGridViewThamSo.Rows[Index].Cells["ColGiaTri"].Value == null)
            {
                MessageBox.Show("Giá trị không được để trống");
                dataGridViewThamSo.CurrentCell = dataGridViewThamSo.Rows[Index].Cells["ColGiaTri"];
                dataGridViewThamSo.BeginEdit(true);
                flag = false;
            }

            if (flag)
            {
                ThamSoDTO thamSoDTO = new ThamSoDTO();
                thamSoDTO.TenThamSo = dataGridViewThamSo.Rows[Index].Cells["ColTenThamSo"].Value.ToString();
                thamSoDTO.GiaTri    = dataGridViewThamSo.Rows[Index].Cells["ColGiaTri"].Value.ToString();
                if (Status == 1)//Them tham so
                {
                    thamSoDTO.MaThamSo = ThamSoBUS.CreateThamSoId();
                    dataGridViewThamSo.Rows[Index].Cells["ColMaThamSo"].Value = thamSoDTO.MaThamSo;
                    dataGridViewThamSo.Rows[Index].Cells["ColSTT"].Value      = (Index + 1).ToString();
                    if (ThamSoBUS.InsertThamSo(thamSoDTO))
                    {
                        dataGridViewThamSo.Rows[Index].ReadOnly = true;
                        MessageBox.Show("Thêm thành công");
                    }
                    else
                    {
                        dataGridViewThamSo.Rows.RemoveAt(Index);
                        MessageBox.Show("Thêm thất bại");
                    }
                }
                else if (Status == 2)
                {
                    thamSoDTO.MaThamSo = dataGridViewThamSo.Rows[Index].Cells["ColMaThamSo"].Value.ToString();
                    if (ThamSoBUS.UpdateThamSoById(thamSoDTO))
                    {
                        dataGridViewThamSo.Rows[Index].ReadOnly = true;
                        MessageBox.Show("Cập nhật thành công");
                    }
                    else
                    {
                        MessageBox.Show("Cập nhật thất bại");
                        dataGridViewThamSo.Rows[Index].Cells["ColTenThamSo"].Value = BackupThamSoDTO.TenThamSo;
                        dataGridViewThamSo.Rows[Index].Cells["ColGiaTri"].Value    = BackupThamSoDTO.GiaTri;
                        dataGridViewThamSo.Rows[Index].ReadOnly = true;
                    }
                }

                Reset();
            }
        }
Пример #2
0
        public bool them(ThamSoDTO ts)
        {
            string query = string.Empty;

            query += "INSERT INTO [ThamSo] ([TuoiCTMin], [TuoiCTMax], [SoLuongCTMin], [SoLuongCTMax], [SoCTNgoaiMax], [TGGhiBanMax])";
            query += "VALUES (@TuoiCTMin,@TuoiCTMax,@SoLuongCTMin,@SoLuongCTMax,@SoCTNgoaiMax,@TGGhiBanMax)";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@TuoiCTMin", ts.TuoiCTMin);
                    cmd.Parameters.AddWithValue("@TuoiCTMax", ts.TuoiCTMax);
                    cmd.Parameters.AddWithValue("@SoLuongCTMin", ts.SoLuongCTMin);
                    cmd.Parameters.AddWithValue("@SoLuongCTMax", ts.SoLuongCTMax);
                    cmd.Parameters.AddWithValue("@SoCTNgoaiMax", ts.SoCTNgoaiMax);
                    cmd.Parameters.AddWithValue("@TGGhiBanMax", ts.TGGhiBanMax);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #3
0
 public bool UpdateRow(ThamSoDTO obj)
 {
     try
     {
         if (_connection.State != ConnectionState.Open)
         {
             _connection.Open();
         }
         string sql = "UPDATE [dbo].[ThamSo]\n"
                      + "   SET [TenThamSo] = @TenThamSo\n"
                      + "      ,[GiaTri] = @GiaTri\n"
                      + " WHERE [MaThamSo] = @MaThamSo";
         var cmd = new SqlCommand(sql, _connection);
         cmd.Parameters.Add("@MaThamSo", SqlDbType.Char).Value  = obj.MaThamSo;
         cmd.Parameters.Add("@TenThamSo", SqlDbType.Char).Value = obj.TenThamSo;
         cmd.Parameters.Add("@GiaTri", SqlDbType.Int).Value     = obj.GiaTri;
         cmd.ExecuteNonQuery();
         _connection.Close();
         return(true);
     }
     catch (Exception ex)
     {
         _connection.Close();
         Console.WriteLine(ex.Message);
     }
     return(false);
 }
        public DataTable LoadThamSo(ThamSoDTO ts)
        {
            Provider provider = new Provider();

            try
            {
                string strSql = "select ts.SoKhachToiDa, ts.SoKhachNuocNgoai, ts.TiLePhuThu, ts.SoKhachNoiDia FROM ThamSo ts";
                provider.Connect();;
                DataTable dt = provider.Select(CommandType.Text, strSql,
                                               new SqlParameter {
                    ParameterName = "@SoKhachToiDa", Value = ts.SoKhachToiDa
                },
                                               new SqlParameter {
                    ParameterName = "@SoKhachNuocNgoai", Value = ts.SoKhachNuocNgoai
                },
                                               new SqlParameter {
                    ParameterName = "@TiLePhuThu", Value = ts.TiLePhuThu
                },
                                               new SqlParameter {
                    ParameterName = "@SoKhachNoiDia", Value = ts.SoKhachNoiDia
                }
                                               );

                return(dt);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
        }
Пример #5
0
        private void QD_BTN_Luu_Click(object sender, EventArgs e)
        {
            QD_BTN_ChinhSua.Enabled = true;
            QD_BTN_Luu.Enabled      = false;
            QD_TB_Nhap.Enabled      = false;
            QD_TB_TienNo.Enabled    = false;
            QD_TB_ToiThieu.Enabled  = false;
            QD_TB_Ton.Enabled       = false;
            QD_CKB.Enabled          = false;
            ThamSoBus        thamsoBus = new ThamSoBus();
            DataTable        dsthamso  = thamsoBus.GetThamSo();
            List <ThamSoDTO> thamso    = new List <ThamSoDTO>();

            thamso.Clear();
            foreach (DataRow dr in dsthamso.Rows)
            {
                var ts = new ThamSoDTO()
                {
                    MaThamSo  = dr["MaThamSo"].ToString().Trim(),
                    TenThamSo = dr["TenThamSo"].ToString().Trim(),
                    GiaTri    = int.Parse(dr["GiaTri"].ToString())
                };
                thamso.Add(ts);
            }
            thamso[0].GiaTri = int.Parse(QD_TB_Nhap.Text);
            thamso[1].GiaTri = int.Parse(QD_TB_Ton.Text);
            thamso[2].GiaTri = int.Parse(QD_TB_ToiThieu.Text);
            thamso[3].GiaTri = int.Parse(QD_TB_TienNo.Text);
            thamso[4].GiaTri = QD_CKB.Checked == true ? 1 : 0;

            foreach (ThamSoDTO ts in thamso)
            {
                thamsoBus.UpdateThamSo(ts);
            }
        }
Пример #6
0
        private void btnthaydoi_Click(object sender, EventArgs e)
        {
            DataTable dt       = ThamSoDAO.GetThamSoAll();
            int       mathamso = int.Parse(dt.Rows[0].ItemArray[0].ToString());
            ThamSoDTO ts       = new ThamSoDTO();

            ts.MaThamSo = mathamso;
            if (chkchophep.Checked == true)
            {
                ts.DieuKienThu = 1;
            }
            else
            {
                ts.DieuKienThu = 0;
            }
            try
            {
                ts.SoLuongNhapMin = UInt64.Parse(txtslnhapmin.Text);
                ts.LuongTonMin    = UInt64.Parse(txtdssltonmin.Text);
                ts.NoMin          = UInt64.Parse(txttiennomin.Text);
                ts.TonSauKhiBan   = UInt64.Parse(txtsltonsaukhiban.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Bạn phải nhập vào kiểu số");
            }
            catch (OverflowException)
            {
                MessageBox.Show("Số không được âm");
            }

            ThamSoDAO.Update(ts);
            MessageBox.Show("Thay đổi thành công");
        }
        public bool suaThamSo(ThamSoDTO thamso)
        {
            string query = string.Empty;

            query += "UPDATE THAMSO SET [SoLuongCayCanhToiDa] = @SoLuongCayCanhToiDa, [SoTienMuaToiDa] = @SoTienMuaToiDa";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@SoTienMuaToiDa", thamso.SoTienToiDaPT);
                    cmd.Parameters.AddWithValue("@SoLuongCayCanhToiDa", thamso.SoCayToiDaPT);

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
        public int SuaThamSo(ThamSoDTO ts)
        {
            Provider provider = new Provider();
            int      n        = 0;

            try
            {
                provider.Connect();

                string sql = "update THAMSO set SoKhachToiDa = @SoKhachToiDa, SoKhachNuocNgoai = @SoKhachNuocNgoai, SoKhachNoiDia = @SoKhachNoiDia, TiLePhuThu = @TiLePhuThu";
                n = provider.ExecuteNonQuery(CommandType.Text, sql,
                                             new SqlParameter {
                    ParameterName = "@SoKhachToiDa", Value = ts.SoKhachToiDa
                },
                                             new SqlParameter {
                    ParameterName = "@SoKhachNuocNgoai", Value = ts.SoKhachNuocNgoai
                },
                                             new SqlParameter {
                    ParameterName = "@SoKhachNoiDia", Value = ts.SoKhachNoiDia
                },
                                             new SqlParameter {
                    ParameterName = "@TiLePhuThu", Value = ts.TiLePhuThu
                }
                                             );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(n);
        }
Пример #9
0
        private void bt_sua_Click(object sender, EventArgs e)
        {
            ThamSoDTO ts = new ThamSoDTO();

            ts.MaTS1      = textBox_MaTS.Text;
            ts.TenThamSo1 = textBox_TenTS.Text;
            ts.GiaTri1    = int.Parse(textBox_GiaTri.Text);
            tsbus         = new ThamSoBUS();
            bool kq = tsbus.sua(ts);

            if (kq == false)
            {
                MessageBox.Show("Sữa bệnh nhân thất bại. Vui lòng kiểm tra lại dũ liệu");
            }
            else
            {
                MessageBox.Show("Sữa bệnh nhân thành công");
            }
            bt_sua.Visible          = true;
            textBox_TenTS.ReadOnly  = true;
            textBox_GiaTri.ReadOnly = true;
            bt_luu.Visible          = false;
            bt_Huy.Visible          = false;
            dataGridView1.Enabled   = false;
        }
Пример #10
0
    private void LayThamSo()
    {
        ThamSoBUS bus = new ThamSoBUS();

        ThamSoDTO dto = bus.LayThamSo();

        XL_THE kq = new XL_THE("ThamSo");

        XL_THUOC_TINH Thuoc_tinh = new XL_THUOC_TINH("GiaTriDiemSo", ((int)dto.GiaTriDiemSo).ToString());

        kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

        Thuoc_tinh = new XL_THUOC_TINH("DiemKhachHangThanThiet", ((int)dto.DiemKhachHangThanThiet).ToString());
        kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

        Thuoc_tinh = new XL_THUOC_TINH("TiLeGiamGiaThucDon", ((int)(dto.TiLeGiamGiaThucDon * 100)).ToString());
        kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

        Thuoc_tinh = new XL_THUOC_TINH("Thue", ((int)(dto.Thue * 100)).ToString());
        kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

        Thuoc_tinh = new XL_THUOC_TINH("GiaTriDoiDiemKhuyenMai", ((int)dto.GiaTriDoiDiemKhuyenMai).ToString());
        kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

        Thuoc_tinh = new XL_THUOC_TINH("GioiHanDoiDiemKhuyenMai", ((int)(dto.GioiHanDoiDiemKhuyenMai * 100)).ToString());
        kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

        XL_CHUOI.XuatXML(Response, kq.Chuoi());
    }
Пример #11
0
        private void btnMacDinh_Click(object sender, EventArgs e)
        {
            this.txtToiThieuMoi.Text    = "150";
            this.txtTonMaxMoi.Text      = "300";
            this.txtTonToiThieuMoi.Text = "20";
            this.txtTienNoMoi.Text      = "20000";
            this.chkQuyDinh4.Checked    = true;
            ThamSoDTO qdMoi = new ThamSoDTO();

            qdMoi = quydinh.QuyDinh();

            qdMoi.SoLuongNhapItNhat        = Convert.ToInt32(this.txtToiThieuMoi.Text);
            qdMoi.SoLuongTonToiDaTruocNhap = Convert.ToInt32(this.txtTonMaxMoi.Text);
            qdMoi.SoLuongTonSauToiThieu    = Convert.ToInt32(this.txtTonToiThieuMoi.Text);
            qdMoi.SoTienNoToiDa            = Convert.ToInt32(this.txtTienNoMoi.Text);
            qdMoi.SuDungQuyDinh4           = 1;
            bool ketqua = quydinh.chinhsuaQuyDinh(qdMoi);

            if (ketqua == true)
            {
                MessageBox.Show("Khôi phục mặc định thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MessageBox.Show("Khôi phục mặc định thất bại \n" + ketqua, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            loadQuyDinh();
        }
Пример #12
0
        public ThamSoDTO GetRow(string maThamSo)
        {
            try
            {
                var obj = new ThamSoDTO();
                if (_connection.State != ConnectionState.Open)
                {
                    _connection.Open();
                }

                SqlCommand command = new SqlCommand("SELECT * FROM [dbo].[ThamSo] WHERE MaThamSo = @mathamso", _connection);
                command.Parameters.Add("@mathamso", SqlDbType.Char).Value = maThamSo;

                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    obj.MaThamSo  = reader["MaThamSo"].ToString();
                    obj.TenThamSo = reader["TenThamSo"].ToString();
                    obj.GiaTri    = (int)reader["GiaTri"];
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                _connection.Close();
                Console.WriteLine(ex.Message);
            }
            return(null);
        }
Пример #13
0
 public static bool CapNhatTSDonGia(ThamSoDTO ts, string t)
 {
     if (ts.DonGia <= 0)
     {
         return(false);
     }
     return(ParameDAO.CapNhatTSDonGia(ts, t));
 }
Пример #14
0
    public bool LuuThamSo(ThamSoDTO ts)
    {
        SqlCommand cmd = CreateCommandStored("spLuuThamSo",
                                             new string[] { "@GiaTriDiemSo", "@DiemKhachHangThanThiet", "@TiLeGiamGiaThucDon", "@Thue", "@GiaTriDoiDiemKhuyenMai", "@GioiHanDoiDiemKhuyenMai" },
                                             new object[] { ts.GiaTriDiemSo, ts.DiemKhachHangThanThiet, ts.TiLeGiamGiaThucDon, ts.Thue, ts.GiaTriDoiDiemKhuyenMai, ts.GioiHanDoiDiemKhuyenMai });

        return(ExecuteNonQuery(cmd));
    }
Пример #15
0
        public static bool UpdateThamSoById(ThamSoDTO thamSoDTO)
        {
            List <SqlParameter> sqlParamas = new List <SqlParameter>();

            sqlParamas.Add(new SqlParameter("@MaThamSo", thamSoDTO.MaThamSo));
            sqlParamas.Add(new SqlParameter("@TenThamSo", thamSoDTO.TenThamSo));
            sqlParamas.Add(new SqlParameter("@GiaTri", thamSoDTO.GiaTri));
            return(DataProvider.ExecuteNoneQuery("usp_UpdateThamSoById", sqlParamas));
        }
        private void btnLapPhieuThuTien_Click(object sender, EventArgs e)
        {
            PhieuThuTienDTO obj = new PhieuThuTienDTO();

            obj.MaKH = this.textBoxMaKH.Text;
            ThamSoDTO ThamSo = new ThamSoDTO();

            ThamSo = busThamSo.QuyDinh();
            QuanLyKhachHangDTO KH = new QuanLyKhachHangDTO();

            ktquydinh4 = ThamSo.SuDungQuyDinh4;
            // sẽ viết sau
            string result;

            KH.MaKH  = this.textBoxMaKH.Text;
            soTienNo = KH.SoTienNo;
            tienThu  = Convert.ToInt32(this.textBoxSoTienThu.Text);
            //Kiểm tra mã khách hàng không được để trống
            if (this.textBoxMaKH.Text == string.Empty)
            {
                MessageBox.Show("Mã khách hàng không được để trống", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                obj.MaKH = this.textBoxMaKH.Text;
            }
            obj.NgayThuTien = this.dtpNgayThuTien.Text;
            obj.MaPT        = this.textBoxMaPhieuThu.Text;
            obj.STT         = Convert.ToInt32(this.textBoxSoTienThu.Text);
            KH = this.busKH.searchKH(KH.MaKH, KH);
            //Quy Dinh 4;
            if (ktquydinh4 == 1)
            {
                if (soTienNo < tienThu)
                {
                    MessageBox.Show("Số tiền thu lớn hơn số tiền khách hàng đang nợ", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                return;
            }
            tienNoMoi = soTienNo - tienThu;

            //obj.Email = this.textBoxEmail.Text;
            //obj.SoTienNo = Convert.ToInt32(this.textBoxSoTienNo.Text);

            result = this.bus.insert(obj);
            if (result == "0")
            {
                MessageBox.Show("Thêm phiếu thu thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            else
            {
                MessageBox.Show("Thêm phiếu thu thất bại.\n" + result, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #17
0
        private void btnThemCT_Click(object sender, EventArgs e)
        {
            CTPhieuNhapSachDTO obj    = new CTPhieuNhapSachDTO();
            ThamSoDTO          ThamSo = new ThamSoDTO();

            ThamSo = busThamSo.QuyDinh();
            string        result;
            QuanLySachDTO Sach = new QuanLySachDTO();

            //List<QuanLySachDTO> lsSach = new List<QuanLySachDTO>();


            obj.MaCT   = this.txtMaCTPN.Text;
            obj.MaPN   = this.txtMaPN.Text;
            obj.MaSach = this.txtMaSach.Text;
            obj.SLN    = Convert.ToInt32(this.txtSoLuongNhap.Text);
            if (obj.SLN < ThamSo.SoLuongNhapItNhat) // quy định 1.1
            {
                MessageBox.Show(string.Format("Số lượng nhập phải lớn hơn số lượng quy định ({0} quyển)", ThamSo.SoLuongNhapItNhat), "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                obj.SLN     = Convert.ToInt32(this.txtSoLuongNhap.Text);
                Sach.MaSach = this.txtMaSach.Text;
                Sach        = this.busSach.laySach(Sach.MaSach, Sach);

                luongton    = Sach.SoLuongTon;
                luongtonTam = luongton;
                //Tính lượng tồn mới
                luongtonMoi = luongton + int.Parse(this.txtSoLuongNhap.Text);
                luongtonMax = ThamSo.SoLuongTonToiDaTruocNhap;
                //Kiểm tra qui định số lượng tồn tối đa trước nhập
                if (luongton < luongtonMax)
                {
                    result = this.bus.insertChiTiet(obj);
                    if (result == "0")
                    {
                        Sach.SoLuongTon = luongtonMoi;
                        busSach.capnhatLuongTon(Sach);
                        MessageBox.Show("Thêm mới chi tiết phiếu nhập thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        buildDanhSachCT();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Thêm mới chi tiết phiếu nhập thất bại.\n" + result, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("Chỉ nhập các đầu sách có lượng tồn ít hơn theo quy định ({0} quyển)", ThamSo.SoLuongTonToiDaTruocNhap), "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Пример #18
0
 public bool UpdateThamSo(ThamSoDTO ts)
 {
     if (objThamSo.IsRowExists(ts.MaThamSo))
     {
         return(objThamSo.UpdateRow(ts));
     }
     else
     {
         return(false);
     }
 }
    protected void LayTiLeGiamGiaThucDon()
    {
        ThamSoBUS bus = new ThamSoBUS();
        ThamSoDTO dto = bus.LayThamSo();

        XL_THE Kq = new XL_THE("THAM_SO");

        Kq.Danh_sach_thuoc_tinh.Add(new XL_THUOC_TINH("TiLeGiam", dto.TiLeGiamGiaThucDon.ToString()));

        XL_CHUOI.XuatChuoi(Response, Kq.Chuoi());
    }
Пример #20
0
        private void frmQuyDinh_Load(object sender, EventArgs e)
        {
            ltkBUS = new LoaiTietKiemBUS();
            tsBUS  = new ThamSoBUS();

            ThamSoDTO ts       = new ThamSoDTO();
            DataTable dtThamSo = tsBUS.getThamSo();                         // get Tham so

            txtTienGuiToiThieu.Text     = (dtThamSo.Rows[0][1]).ToString(); // tu dong hien thi tham so
            txtThoiGianGuiToiThieu.Text = (dtThamSo.Rows[0][3]).ToString(); // tu dong hien thi tham so
            loadLoaiTietKiemVao_Combobox();                                 // load thong tin cac loai tiet kiem dang co
        }
Пример #21
0
        public ThamSoDTO getData(string id) //hàm lấy dữ liệu từ dtb
        {
            ThamSoDTO tsDTO = new ThamSoDTO();
            string    query = string.Empty;

            query += "SELECT * FROM ThamSo WHERE MaThamSo = @ID";
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@ID", id);
                    try
                    {
                        conn.Open();
                        using (SqlDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                tsDTO.MaThamSo     = (string)dr["MaThamSo"];
                                tsDTO.TuoiCTMin    = (int)dr["TuoiCTMin"];
                                tsDTO.TuoiCTMax    = (int)dr["TuoiCTMax"];
                                tsDTO.SoLuongCTMin = (int)dr["SoLuongCTMin"];
                                tsDTO.SoLuongCTMax = (int)dr["SoLuongCTMax"];
                                tsDTO.SoCTNgoaiMax = (int)dr["SoCTNgoaiMax"];
                                tsDTO.TGGhiBanMax  = (int)dr["TGGhiBanMax"];
                                tsDTO.DiemThang    = (int)dr["DiemThang"];
                                tsDTO.DiemHoa      = (int)dr["DiemHoa"];
                                tsDTO.DiemThua     = (int)dr["DiemThua"];
                                tsDTO.Diem         = (int)dr["Diem"];
                                tsDTO.HieuSo       = (int)dr["HieuSo"];
                                tsDTO.BTSK         = (int)dr["BTSK"];
                                tsDTO.KQDK         = (int)dr["KQDK"];
                            }
                        }
                        conn.Close();
                        conn.Dispose();
                    }
                    catch (Exception ex)
                    {
                        conn.Close();
                    }
                }
            }
            if (tsDTO.MaThamSo == null)
            {
                return(null);
            }
            return(tsDTO);
        }
Пример #22
0
        public static bool CapNhatTSHeSo(ThamSoDTO infor)
        {
            SqlParameter heso = new SqlParameter("@HeSo", infor.HeSo);

            try
            {
                context.Database.ExecuteSqlCommand("spCapNhatTSHeSo @HeSo", heso);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #23
0
        public static bool CapNhatTSPhuThu(ThamSoDTO infor)
        {
            SqlParameter phuthu = new SqlParameter("@PhuThu", infor.PhuThu);

            try
            {
                context.Database.ExecuteSqlCommand("spCapNhatTSPhuThu @PhuThu", phuthu);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #24
0
        public static bool CapNhatTSSoKhachToiDa(ThamSoDTO infor)
        {
            SqlParameter toida = new SqlParameter("@SoKhachToiDa", infor.SLKhachToiDa);

            try
            {
                context.Database.ExecuteSqlCommand("spCapNhatTSSoKhachToiDa @SoKhachToiDa", toida);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #25
0
        public static bool CapNhatTSDonGia(ThamSoDTO ts, string t)
        {
            SqlParameter dongia       = new SqlParameter("@DonGia", ts.DonGia);
            SqlParameter tenloaiphong = new SqlParameter("@TenLoaiPhong", t);

            try
            {
                context.Database.ExecuteSqlCommand("spCapNhatTSDonGia  @TenLoaiPhong ,@DonGia ", dongia, tenloaiphong);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #26
0
    public int TinhSoDiemToiDa(decimal giatri, int diemht)
    {
        ThamSoDTO tsDto   = (new ThamSoBUS()).LayThamSo();
        decimal   gioihan = giatri * (decimal)tsDto.GioiHanDoiDiemKhuyenMai;
        decimal   diem    = Math.Round(gioihan / tsDto.GiaTriDoiDiemKhuyenMai);
        int       diemtd  = int.Parse((diem.ToString()));

        if (diemtd <= diemht)
        {
            return(diemtd);
        }
        else
        {
            return(diemht);
        }
    }
Пример #27
0
        private void btnThayDoiThoiGianGuiToiThieu_Click(object sender, EventArgs e)
        {
            ThamSoDTO ts = new ThamSoDTO();

            ts.ISoNgayGuiToiThieu = int.Parse(txtThoiGianGuiToiThieu.Text);

            bool kq = tsBUS.suaThamSo(ts);

            if (kq == false)
            {
                MessageBox.Show("Thay đổi Thời gian gửi tối thiểu thất bại. Vui lòng kiểm tra lại dũ liệu");
            }
            else
            {
                MessageBox.Show("Thay đổi Thời gian gửi tối thiểu thành công");
            }
        }
        public List <ThamSoDTO> selectThamSo()
        {
            string query = string.Empty;

            query += "SELECT[SoTienMuaToiDa],[SoLuongCayCanhToiDa]";
            query += "FROM [THAMSO]";

            List <ThamSoDTO> lsThamSo = new List <ThamSoDTO>();

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;

                    try
                    {
                        con.Open();
                        SqlDataReader reader = null;
                        reader = cmd.ExecuteReader();
                        if (reader.HasRows == true)
                        {
                            while (reader.Read())
                            {
                                ThamSoDTO thamSo = new ThamSoDTO();
                                thamSo.SoTienToiDaPT = int.Parse(reader["SoTienMuaToiDa"].ToString());
                                thamSo.SoCayToiDaPT  = int.Parse(reader["SoLuongCayCanhToiDa"].ToString());
                                lsThamSo.Add(thamSo);
                            }
                        }

                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(null);
                    }
                }
            }
            return(lsThamSo);
        }
Пример #29
0
    public int CapNhatDiemKMTheoQuiDinh(int makh, int diemcu, decimal giatri, decimal tienkm)
    {
        ThamSoDTO tsDto  = (new ThamSoBUS()).LayThamSo();
        int       diemdc = 0;

        //cong them diem neu don hang > gia tri qui dinh
        if (giatri > tsDto.GiaTriDiemSo)
        {
            diemdc = (int)(Math.Round(giatri / tsDto.GiaTriDiemSo));
        }
        //tru so diem su dung
        int diemsd = TinhDiemKhuyenMai(tienkm);

        int diemmoi = diemcu + diemdc - diemsd;

        (new KhachHangBUS()).CapNhatDiemKhuyenMai(makh, diemmoi);
        return(diemmoi);
    }
Пример #30
0
        private ThamSoDTO QuyDinh()
        {
            ThamSoDTO q = new ThamSoDTO();

            q.SoLuongNhapItNhat        = int.Parse(this.txtToiThieuMoi.Text);
            q.SoLuongTonToiDaTruocNhap = int.Parse(this.txtTonMaxMoi.Text);
            q.SoLuongTonSauToiThieu    = int.Parse(this.txtTonToiThieuMoi.Text);
            q.SoTienNoToiDa            = int.Parse(this.txtTienNoMoi.Text);
            if (this.chkQuyDinh4.Checked == true)
            {
                q.SuDungQuyDinh4 = 1;
            }
            else
            {
                q.SuDungQuyDinh4 = 0;
            }
            return(q);
        }