コード例 #1
0
        public bool ThuChi_Insert(ThuChi_Info p_ThuChi_Info)
        {
            try
            {
                SqlParameter[] spParameter = new SqlParameter[7];

                int i = 0;
                spParameter[i]           = new SqlParameter("@SoHoadon", SqlDbType.NVarChar);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.SoHoadon;

                i++;
                spParameter[i]           = new SqlParameter("@Create_Date", SqlDbType.DateTime);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.Create_Date;

                i++;
                spParameter[i]           = new SqlParameter("@ThuChi", SqlDbType.Int);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.ThuChi;

                i++;
                spParameter[i]           = new SqlParameter("@Price", SqlDbType.Decimal);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.Price;

                i++;
                spParameter[i]           = new SqlParameter("@DienGiai", SqlDbType.NVarChar);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.DienGiai;

                i++;
                spParameter[i]           = new SqlParameter("@Customer_Id", SqlDbType.Int);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.Customer_Id;

                i++;
                spParameter[i]           = new SqlParameter("@Supplier_Id", SqlDbType.Int);
                spParameter[i].Direction = ParameterDirection.Input;
                spParameter[i].Value     = p_ThuChi_Info.Supplier_Id;


                SqlHelper.ExecuteNonQuery(CommonData.ConnectionString, CommandType.StoredProcedure, "proc_ThuChi_Insert", spParameter);

                return(true);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
                return(false);
            }
        }
コード例 #2
0
        ThuChi_Info Get_ThuChi()
        {
            try
            {
                ThuChi_Info _ThuChi_Info = new ThuChi_Info();

                _ThuChi_Info.SoHoadon    = txtSoHoaDon.Text;
                _ThuChi_Info.Price       = Convert.ToDecimal(txtTotal_Price.Text);
                _ThuChi_Info.ThuChi      = Convert.ToInt16(ThuChi_Type.Nhap_Hang);
                _ThuChi_Info.Create_Date = DateTime.Now;
                _ThuChi_Info.DienGiai    = txtNote.Text;
                _ThuChi_Info.Supplier_Id = Convert.ToInt16(cboSupplier.SelectedValue);
                _ThuChi_Info.Customer_Id = 0;
                return(_ThuChi_Info);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
                return(null);
            }
        }
コード例 #3
0
        ThuChi_Info Get_ThuChi()
        {
            try
            {
                ThuChi_Info _ThuChi_Info = new ThuChi_Info();

                _ThuChi_Info.SoHoadon = txtSaleHeader.Text;
                _ThuChi_Info.Price    = Convert.ToDecimal(txtPayPrice.Text);

                _ThuChi_Info.ThuChi      = Convert.ToInt16(ThuChi_Type.Ban_Buon);
                _ThuChi_Info.Create_Date = DateTime.Now;
                _ThuChi_Info.DienGiai    = txtNote.Text;
                _ThuChi_Info.Supplier_Id = 0;
                _ThuChi_Info.Customer_Id = 0; // ID khách hàng
                return(_ThuChi_Info);
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
                return(null);
            }
        }
コード例 #4
0
        void Accept()
        {
            try
            {
                if (!CheckValidate())
                {
                    return;
                }

                MessageBoxResult result = NoteBox.Show("Bạn có muốn tạo hóa đơn này hay không?", "Thông báo", NoteBoxLevel.Question);
                if (result != MessageBoxResult.Yes)
                {
                    return;
                }

                // insert vao bảng sale header

                Sale_Header_Controller  _Sale_Header_Controller = new Sale_Header_Controller();
                List <Sale_Detail_Info> _Sale_Detail_Info       = new List <Sale_Detail_Info>();

                Sale_Header_Info _Sale_Header_Info = Get_Sale_Header(ref _Sale_Detail_Info);

                if (_Sale_Header_Info == null)
                {
                    NoteBox.Show("Lỗi rồi Nắng ơi", "", NoteBoxLevel.Error);
                    return;
                }

                decimal _id = 0;

                if (_Sale_Header_Controller.Sale_Header_Insert(_Sale_Header_Info, ref _id))
                {
                    #region insert vào bảng thu chi
                    ThuChi_Controller _ThuChi_Controller = new ThuChi_Controller();
                    ThuChi_Info       _ThuChi_Info       = Get_ThuChi();
                    _ThuChi_Info.Customer_Id = _Sale_Header_Info.Customer_Id;
                    if (_ThuChi_Info == null)
                    {
                        NoteBox.Show("Lỗi rồi Nắng ơi", "", NoteBoxLevel.Error);
                        _Sale_Header_Controller.Sale_Header_Delete(_id);
                        return;
                    }
                    if (!_ThuChi_Controller.ThuChi_Insert(_ThuChi_Info))
                    {
                        NoteBox.Show("Lỗi rồi Nắng ơi", "", NoteBoxLevel.Error);
                        _Sale_Header_Controller.Sale_Header_Delete(_id);
                        return;
                    }
                    #endregion

                    foreach (Sale_Detail_Info item in _Sale_Detail_Info)
                    {
                        _Sale_Header_Controller.Sale_Detail_Insert(item, _id);
                        _ThuChi_Controller.Update_Product_Sale_Count(item.Product_Id, item.Count, item.Color_Id);
                    }

                    Export();

                    NoteBox.Show("Tạo hóa đơn thành công");
                    this.Close();
                }
                else
                {
                    NoteBox.Show("Lỗi rồi", "", NoteBoxLevel.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }
コード例 #5
0
        void Accept()
        {
            try
            {
                if (!CheckValidate_F())
                {
                    return;
                }

                #region  Insert vào bảng Items trước, trả ra mã ID vừa nhập

                Product_Info _Product_Info = Get_ItemInfo_FromControl();
                if (ckb_Is_XuatDu.IsChecked == true)
                {
                    _Product_Info.Is_XuatDu = 1;
                }
                else
                {
                    _Product_Info.Is_XuatDu = 0;
                }

                Product_Controller _Product_Controller = new Product_Controller();
                ThuChi_Controller  _ThuChi_Controller  = new ThuChi_Controller();
                if (!_Product_Controller.Product_Insert(_Product_Info, ref c_id_insert))
                {
                    NoteBox.Show("Lỗi rồi Nắng ơi", "", NoteBoxLevel.Error);
                    return;
                }
                else
                {
                    #region insert vào bảng thu chi
                    ThuChi_Info _ThuChi_Info = Get_ThuChi();
                    if (_ThuChi_Info == null)
                    {
                        NoteBox.Show("Lỗi rồi Nắng ơi", "", NoteBoxLevel.Error);
                        _Product_Controller.Product_Delete(c_id_insert);
                        return;
                    }
                    if (!_ThuChi_Controller.ThuChi_Insert(_ThuChi_Info))
                    {
                        NoteBox.Show("Lỗi rồi Nắng ơi", "", NoteBoxLevel.Error);
                        _Product_Controller.Product_Delete(c_id_insert);
                        return;
                    }
                    #endregion

                    foreach (Product_Detail_Info item in c_lst_Products_Detail)
                    {
                        item.Product_Id = c_id_insert;

                        if (!_Product_Controller.Product_Detail_Insert(item))
                        {
                            NoteBox.Show("Lỗi rồi", "", NoteBoxLevel.Error);
                            _Product_Controller.Product_Detail_Delete(c_id_insert);
                            _Product_Controller.Product_Delete(c_id_insert);
                            return;
                        }
                    }

                    NoteBox.Show("Thêm mới thành công");
                    this.c_ok = 1;
                    this.Close();
                }


                #endregion
            }
            catch (Exception ex)
            {
                CommonData.log.Error(ex.ToString());
            }
        }