void LoadData() { try { decimal _total_p = 0; Sale_Header_Controller _Product_Controller = new Sale_Header_Controller(); c_list_Product_Buy = _Product_Controller.Get_Product_By_Sale_Header(c_Sale_Header_Info.SoHoaDon); dgrProduct_Detail.ItemsSource = c_list_Product_Buy; c_hs_Product = new Hashtable(); foreach (Product_Info item in c_list_Product_Buy) { item.Change_Type = Convert.ToInt16(Change_Product_Type.Normal); item.Total_Price = item.DonGia_By_Type * item.Count_Sale_By_Header; _total_p += item.DonGia_By_Type * item.Count_Sale_By_Header; c_hs_Product[item.Product_Code.ToUpper()] = c_Product_Info_Search; } txtTotalPrice.Text = _total_p.ToString(); if (c_Sale_Header_Info.SalesType == Convert.ToInt16(ThuChi_Type.Ban_Buon)) { this.Title = "Hóa đơn bán buôn " + c_Sale_Header_Info.SoHoaDon; } else if (c_Sale_Header_Info.SalesType == Convert.ToInt16(ThuChi_Type.Ban_Le)) { this.Title = "Hóa đơn bán lẻ " + c_Sale_Header_Info.SoHoaDon; } txtCustomer_Name.Text = c_Sale_Header_Info.Customer_Name; txtDiscount.Text = c_Sale_Header_Info.Discount.ToString(); txtPayPrice.Text = c_Sale_Header_Info.Total_Amount.ToString(); txtSaleDate.Text = c_Sale_Header_Info.Sale_Date.ToString("dd/MM/yyyy"); txtShipPrice.Text = c_Sale_Header_Info.Ship_Price.ToString(); //txtPhone.Text = c_Sale_Header_Info. if (c_Sale_Header_Info.Per_Discont != 0) { txtPerDiscount.Text = c_Sale_Header_Info.Per_Discont.ToString("###,###,0") + "%"; } else { txtPerDiscount.Text = c_Sale_Header_Info.Per_Discount_Price.ToString(); } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
void Create_Sale_Header_Code() { try { Sale_Header_Controller _Sale_Header_Controller = new Sale_Header_Controller(); // lấy ra id hiện tại của thằng product decimal _max_id = _Sale_Header_Controller.Sale_Header_Get_Max_Id(); txtSaleHeader.Text = "HD_SALE_TRADE_" + DateTime.Now.ToString("dd_MM_yyyy") + "_" + (_max_id + 1).ToString(); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
void Accept() { try { MessageBoxResult result = NoteBox.Show("Bạn có muốn thay đổi hóa đơn này hay không form hay không?", "Thông báo", NoteBoxLevel.Question); if (result != MessageBoxResult.Yes) { return; } Sale_Header_Controller _Sale_Header_Controller = new Sale_Header_Controller(); decimal _per_dc = 0; foreach (Product_Info item in c_lst_Product_Delete) { if (item.Change_Type == Convert.ToInt16(Change_Product_Type.Normal)) { _Sale_Header_Controller.Change_Product_ByHeader_Old(c_Sale_Header_Info, item.Product_Id, item.Count_Sale_By_Header, Convert.ToDecimal(txtPayPrice.Text), DateTime.Now); } } foreach (Product_Info item in c_lst_Product_Add_New) { if (item.Change_Type == Convert.ToInt16(Change_Product_Type.AddNew)) { _Sale_Header_Controller.Change_Product_ByHeader_New(c_Sale_Header_Info, item.Product_Id, item.Count_Sale_By_Header, _per_dc, Convert.ToDecimal(txtPayPrice.Text), DateTime.Now); } } NoteBox.Show("Thay đổi hóa đơn thành công"); c_ok = true; this.Close(); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
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()); } }