Beispiel #1
0
        public DataTable tim(BaoCaoDoanhThuDTO dt)
        {
            DataTable load  = new DataTable();
            string    query = string.Empty;

            query += "Select [maDaiLy] as N'Mã Đại Lý', [thang] as N'Tháng', [soPhieuXuat] as N'Số Phiếu Xuất', [tongTriGia] as N'Tổng Trị Giá', [tyLe] as N'Tỷ Lệ' from [BaoCaoDoanhThu] ";
            query += "Where [BaoCaoDoanhThu].[thang] = @thang";

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

                    cmd.Parameters.AddWithValue("@thang", dt.thang);

                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    load.Load(reader);
                    con.Close();
                    con.Dispose();
                }
            }

            return(load);
        }
Beispiel #2
0
        public static List <BaoCaoDoanhThuDTO> DoanhThuTheoLoaiPhongTheoThang(BaoCaoDoanhThuDTO infor)
        {
            DateTime ntm_min = Convert.ToDateTime("1990-01-01");
            DateTime ntm_max = Convert.ToDateTime("1990-01-31");
            string   n1 = "-01"; string n2 = "-31"; string t = (infor.Thang).ToString(); string nam = (infor.Nam).ToString();

            if (infor.Thang == 2)
            {
                if ((infor.Nam % 4 != 0) || ((infor.Nam % 100 == 0) && (infor.Nam % 400 != 0)))
                {
                    n2 = "-28";
                }
                else
                {
                    n2 = "-29";
                }
            }
            else if (infor.Thang == 4 || infor.Thang == 6 || infor.Thang == 9 || infor.Thang == 11)
            {
                n2 = "-30";
            }
            string ntmold = nam + "-" + t + n1;
            string ntmnew = nam + "-" + t + n2;

            ntm_min = Convert.ToDateTime(ntmold);
            ntm_max = Convert.ToDateTime(ntmnew);
            return(BaoCaoDAO.DoanhThuTheoLoaiPhongTheoThang(ntm_min, ntm_max));
        }
Beispiel #3
0
        private void tim_btn_Click(object sender, EventArgs e)
        {
            BaoCaoDoanhThuDTO dt = new BaoCaoDoanhThuDTO();

            dt.thang = int.Parse(thang_txt.Text);
            doanhThuGrid.DataSource = doanhThuBUS.tim(dt);
        }
 public DataTable tim(BaoCaoDoanhThuDTO dt)
 {
     return(doanhThuDAL.tim(dt));
 }
Beispiel #5
0
        private void btnXem_Click(object sender, EventArgs e)
        {
            BaoCaoDoanhThuDTO        infor = new BaoCaoDoanhThuDTO();
            List <BaoCaoDoanhThuDTO> dlst  = new List <BaoCaoDoanhThuDTO>();

            if (txtNam.Text == "" && cmbThang.Text == "")
            {
                decimal sum = 0;
                lst = BaoCaoBUS.TinhTongDoanhThuTheoLoaiPhong();
                for (int i = 0; i < lst.Count; i++)
                {
                    lst[i].TongDoanhThu = Convert.ToDecimal(string.Format("{0:0,0}", lst[i].TongDoanhThu));
                }
                gridControl1.DataSource = lst;
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    sum += lst[i].TongDoanhThu.Value;
                }
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    decimal cd = (lst[i].TongDoanhThu.Value * 100) / sum;
                    cd          = Math.Round(cd, 2);
                    lst[i].TiLe = (cd).ToString() + "%";
                }
                //btnLuu.Enabled = false;
                txtTongTien.Text = string.Format("{0:0,0 VNĐ}", sum);
            }

            else if (txtNam.Text != "" && cmbThang.Text != "")
            {
                decimal sum = 0;
                infor.Thang = Convert.ToInt32(cmbThang.Text);
                infor.Nam   = Convert.ToInt32(txtNam.Text);

                /*try
                 * {
                 *  dlst = BaoCaoBUS.LayMaBCDoanhThuKeTiep();
                 *  infor.MaBCDoanhThu = dlst[0].MaBCDoanhThu + 1;
                 *  dlst = BaoCaoBUS.LayMaBCCTDoanhThuKeTiep();
                 *  infor.MaCTBCDoanhThu = dlst[0].MaCTBCDoanhThu + 1;
                 * }
                 * catch
                 * {
                 *  infor.MaBCDoanhThu = 1;
                 *  infor.MaCTBCDoanhThu = 1;
                 * }*/
                lst = BaoCaoBUS.DoanhThuTheoLoaiPhongTheoThang(infor);
                for (int i = 0; i < lst.Count; i++)
                {
                    lst[i].TongDoanhThu = Convert.ToDecimal(string.Format("{0:0,0}", lst[i].TongDoanhThu));
                }
                gridControl1.DataSource = lst;
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    sum += lst[i].TongDoanhThu.Value;
                }
                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    decimal cd = (lst[i].TongDoanhThu.Value * 100) / sum;
                    cd           = Math.Round(cd, 2);
                    lst[i].TiLe  = (cd).ToString() + "%";
                    lst[i].Thang = Convert.ToInt32(cmbThang.Text);
                    lst[i].Nam   = Convert.ToInt32(txtNam.Text);
                    //lst[i].MaBCDoanhThu = infor.MaBCDoanhThu;
                    //lst[i].MaCTBCDoanhThu = infor.MaCTBCDoanhThu;
                }
                txtTongTien.Text = string.Format("{0:0,0 VNĐ}", sum);
                //btnLuu.Enabled = true;
            }
        }