Example #1
0
 public bool AddChiTiet(ChiTietBaoCaoTon ctbct)
 {
     try
     {
         if (_connection.State != ConnectionState.Open)
         {
             _connection.Open();
         }
         string sql = "insert into ChiTietBaoCaoTon values(@MaChiTiet," +
                      "@MaBaoCaoTon," +
                      "@MaSach," +
                      "@TonDau," +
                      "@TonCuoi," +
                      "@PhatSinh)";
         SqlCommand cmd = new SqlCommand(sql, _connection);
         cmd.Parameters.Add("@MaChiTiet", SqlDbType.Char).Value   = ctbct.MaChiTietBaoCaoTon;
         cmd.Parameters.Add("@MaBaoCaoTon", SqlDbType.Char).Value = ctbct.MaBaoCaoTon;
         cmd.Parameters.Add("@MaSach", SqlDbType.Char).Value      = ctbct.MaSach;
         cmd.Parameters.Add("@TonDau", SqlDbType.Int).Value       = ctbct.TonDau;
         cmd.Parameters.Add("@TonCuoi", SqlDbType.Int).Value      = ctbct.TonCuoi;
         cmd.Parameters.Add("@PhatSinh", SqlDbType.Int).Value     = ctbct.PhatSinh;
         cmd.ExecuteNonQuery();
         _connection.Close();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "jhgjdhghfghjgfh");
         _connection.Close();
     }
     return(false);
 }
Example #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            DateTime         today   = DateTime.Now;
            string           maBCT   = BaoCaoTonBLL.GetMaBCT(today.Month, today.Year);
            string           maCTBCT = ChiTietBaoCaoTonBLL.getMaCTBCT(maBCT, cboPhuTung.Text);
            ChiTietBaoCaoTon chitiet = new ChiTietBaoCaoTon();

            chitiet.MaBCT    = maBCT;
            chitiet.MaCTBCT  = maCTBCT;
            chitiet.TenPT    = cboPhuTung.Text;
            chitiet.TonCuoi  = int.Parse(txtSL.Text);
            chitiet.PhatSinh = 0;
            chitiet.TonDau   = 0;
            ChiTietBaoCaoTonBLL.capNhatTonCuoi(chitiet);

            decimal thanhTien = decimal.Parse(txtThanhTien.Text);

            txtTongTien.Text = string.Format("{0:0,0}", decimal.Parse(tongTien.ToString()));

            string maCTPSC            = ChiTietPhieuSuaChuaBLL.AutoMACTSC();
            ChiTietPhieuSuaChua ctpsc = new ChiTietPhieuSuaChua(maCTPSC, txtMaPhieu.Text, cboPhuTung.SelectedValue.ToString(), int.Parse(txtSL.Text), cboNoiDung.Text, decimal.Parse(txtThanhTien.Text));

            int soLuongPTTon = int.Parse(PhuTungBLL.LaySoLuongPhuTung(cboPhuTung.Text));

            try
            {
                if (soLuongPTTon < int.Parse(txtSL.Text))
                {
                    MessageBox.Show("Số lượng phụ tùng trong kho không đủ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    ChiTietPhieuSuaChuaBLL.ThemCTPSC(ctpsc);
                    GetDataGridView();
                    tongTien        += thanhTien;
                    txtTongTien.Text = string.Format("{0:0,0}", decimal.Parse(tongTien.ToString()));
                    MessageBox.Show("Thêm chi tiết thành công!", "Thông báo", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            txtDonGia.Clear();
            txtSL.Clear();
            txtThanhTien.Clear();
            txtTienCong.Clear();
            cboNoiDung.Text = "";
            cboPhuTung.Text = "";
        }
Example #3
0
        public static void CapNhatPhatSinh(ChiTietBaoCaoTon chiTiet)
        {
            DataAccessHelper db  = new DataAccessHelper();
            SqlCommand       cmd = db.Command("CAPNHATPHATSINH");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MACTBCT", chiTiet.MaCTBCT);
            cmd.Parameters.AddWithValue("@SL", chiTiet.PhatSinh);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            db.dt = new DataTable();
            da.Fill(db.dt);
        }
Example #4
0
        public static void themChiTietBCT(ChiTietBaoCaoTon chitiet)
        {
            DataAccessHelper db  = new DataAccessHelper();
            SqlCommand       cmd = db.Command("THEMCT_BCT");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MACTBCT", chitiet.MaCTBCT);
            cmd.Parameters.AddWithValue("@MABC", chitiet.MaBCT);
            cmd.Parameters.AddWithValue("@TENPT", chitiet.TenPT);
            cmd.Parameters.AddWithValue("@TONDAU", chitiet.TonDau);
            cmd.Parameters.AddWithValue("@PHATSINH", chitiet.PhatSinh);
            cmd.Parameters.AddWithValue("@TONCUOI", chitiet.TonCuoi);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            db.dt = new DataTable();
            da.Fill(db.dt);
        }
Example #5
0
        public static void ThemBC(BaoCaoTon baoCao)
        {
            BaoCaoTonDAL.ThemBaoCao(baoCao);
            DataTable dt = PhuTungBLL.ListPhuTung();

            foreach (DataRow row in dt.Rows)
            {
                ChiTietBaoCaoTon chiTiet = new ChiTietBaoCaoTon();
                chiTiet.MaCTBCT  = ChiTietBaoCaoTonBLL.AutoMaCTBCT();
                chiTiet.MaBCT    = baoCao.MaBCT;
                chiTiet.TenPT    = row.ItemArray[1].ToString();
                chiTiet.TonDau   = int.Parse(PhuTungBLL.LaySoLuongPhuTung(chiTiet.TenPT));
                chiTiet.TonCuoi  = chiTiet.TonDau;
                chiTiet.PhatSinh = 0;

                ChiTietBaoCaoTonBLL.themChiTietBaoCao(chiTiet);
            }
        }
Example #6
0
        private void btnThemSL_Click(object sender, EventArgs e)
        {
            int           soluong = int.Parse(txtSoLuong.Text);
            frmMuaPhuTung form    = new frmMuaPhuTung(txtSoLuong);

            form.ShowDialog();
            if (btnThayDoi.Enabled)
            {
                PhuTung phuTung = new PhuTung();
                phuTung.MaPhuTung  = txtMaVTPT.Text;
                phuTung.TenPhuTung = txtTenPT.Text;
                phuTung.SoLuong    = int.Parse(txtSoLuong.Text);

                //cap nhat phat sinh
                DateTime today = DateTime.Now;
                string   maBCT = BaoCaoTonBLL.GetMaBCT(today.Month, today.Year);

                if (maBCT == "")
                {
                    BaoCaoTon baocao = new BaoCaoTon();

                    baocao.MaBCT = BaoCaoTonBLL.AutoMABCT();
                    maBCT        = baocao.MaBCT;
                    baocao.Thang = today.Month;
                    baocao.Nam   = today.Year;
                    BaoCaoTonBLL.ThemBC(baocao);
                }

                string           maCTBCT = ChiTietBaoCaoTonBLL.getMaCTBCT(maBCT, phuTung.TenPhuTung);
                ChiTietBaoCaoTon chitiet = new ChiTietBaoCaoTon();

                chitiet.MaBCT    = maBCT;
                chitiet.MaCTBCT  = maCTBCT;
                chitiet.TenPT    = phuTung.TenPhuTung;
                chitiet.TonCuoi  = 0;
                chitiet.PhatSinh = int.Parse(txtSoLuong.Text) - soluong;
                chitiet.TonDau   = 0;
                ChiTietBaoCaoTonBLL.capNhatPhatSinh(chitiet);

                PhuTungBLL.ThayDoiSoLuongPhuTung(phuTung);
                GetDataGridView();
            }
        }
Example #7
0
 public static void capNhatPhatSinh(ChiTietBaoCaoTon chitiet)
 {
     ChiTietBaoCaoTonDAL.CapNhatPhatSinh(chitiet);
 }
Example #8
0
 public static void capNhatTonCuoi(ChiTietBaoCaoTon chitiet)
 {
     ChiTietBaoCaoTonDAL.CapNhatTonCuoi(chitiet);
 }
Example #9
0
 public static void themChiTietBaoCao(ChiTietBaoCaoTon chitiet)
 {
     ChiTietBaoCaoTonDAL.themChiTietBCT(chitiet);
 }
Example #10
0
 public bool AddChiTietBaoCao(ChiTietBaoCaoTon ctbct)
 {
     return(objCTBCT.AddChiTiet(ctbct));
 }