void Chage_Product() { try { int _row_select = dgrSaleHeader.SelectedIndex; Sale_Header_Info _Sale_Header_Info = (Sale_Header_Info)dgrSaleHeader.SelectedItem; if (_Sale_Header_Info == null) { return; } Change_HeaderProduct_Detail _View_HeaderProduct_Detail = new Change_HeaderProduct_Detail(); _View_HeaderProduct_Detail.Owner = Window.GetWindow(this); _View_HeaderProduct_Detail.c_Sale_Header_Info = _Sale_Header_Info; _View_HeaderProduct_Detail.ShowDialog(); if (_View_HeaderProduct_Detail.c_ok == true) { LoadData(); DataGridHelper.NVSFocus(dgrSaleHeader, 0, 0); } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
public bool Change_Product_ByHeader_New(Sale_Header_Info p_Sale_Header_Info, int p_new_product_id, decimal p_new_count, decimal p_per_discount, decimal p_new_total_amount, DateTime p_modifi_date) { try { SqlParameter[] spParameter = new SqlParameter[7]; int i = 0; // 1 spParameter[i] = new SqlParameter("@SoHoaDon", SqlDbType.NVarChar); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.SoHoaDon; i++;//2 spParameter[i] = new SqlParameter("@Sale_Header_Id", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Sale_Header_Id; i++; //3 spParameter[i] = new SqlParameter("@New_Product_Id", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_new_product_id; i++; //4 spParameter[i] = new SqlParameter("@New_Count", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_new_count; i++; //5 spParameter[i] = new SqlParameter("@Per_Discount", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_per_discount; i++; //6 spParameter[i] = new SqlParameter("@New_Total_Price", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_new_total_amount; i++; //7 spParameter[i] = new SqlParameter("@Modifi_Date", SqlDbType.Date); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_modifi_date; SqlHelper.ExecuteNonQuery(CommonData.ConnectionString, CommandType.StoredProcedure, "proc_Change_Product_By_Header", spParameter); return(true); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); return(false); } }
void Sale_Header_View() { try { int _row_select = dgrSaleHeader.SelectedIndex; Sale_Header_Info _Sale_Header_Info = (Sale_Header_Info)dgrSaleHeader.SelectedItem; if (_Sale_Header_Info == null) { return; } View_HeaderProduct_Detail _View_HeaderProduct_Detail = new View_HeaderProduct_Detail(); _View_HeaderProduct_Detail.Owner = Window.GetWindow(this); _View_HeaderProduct_Detail.c_Sale_Header_Info = _Sale_Header_Info; _View_HeaderProduct_Detail.ShowDialog(); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
Sale_Header_Info Get_Sale_Header(ref List <Sale_Detail_Info> p_Sale_Detail_Info) { try { Sale_Header_Info _Sale_Header_Info = new Sale_Header_Info(); _Sale_Header_Info.UserName = CommonData.c_Urser_Info.User_Name; _Sale_Header_Info.Customer_Id = Insert_Customer(); _Sale_Header_Info.BranchId = 0; _Sale_Header_Info.Sale_Date = ConvertData.ConvertString2Date(dpSaleDate.Text); _Sale_Header_Info.SalesType = Convert.ToInt16(ThuChi_Type.Ban_Buon); _Sale_Header_Info.Total_Amount = Convert.ToDecimal(txtPayPrice.Text); _Sale_Header_Info.Debt_Amount = 0; _Sale_Header_Info.CreatedDate = DateTime.Now; _Sale_Header_Info.Comment = txtNote.Text; _Sale_Header_Info.SoHoaDon = txtSaleHeader.Text; if (txtShipPrice.Text != "") { _Sale_Header_Info.Ship_Price = Convert.ToDecimal(txtShipPrice.Text); } else { _Sale_Header_Info.Ship_Price = 0; } if (txtDiscount.Text != "") { _Sale_Header_Info.Discount = Convert.ToDecimal(txtDiscount.Text); } else { _Sale_Header_Info.Discount = 0; } if (txtPerDiscount.Text.Contains("%")) { _Sale_Header_Info.Per_Discont = Convert.ToDecimal(txtPerDiscount.Text.Remove(txtPerDiscount.Text.Length - 1, 1)); _Sale_Header_Info.Per_Discount_Price = 0; } else { _Sale_Header_Info.Per_Discont = 0; if (txtPerDiscount.Text != "" && txtPerDiscount.Text != "0") { _Sale_Header_Info.Per_Discount_Price = Convert.ToDecimal(txtPerDiscount.Text); } else { _Sale_Header_Info.Per_Discount_Price = 0; } } _Sale_Header_Info.Pay_Type = Convert.ToInt16(cboPayType.SelectedValue); p_Sale_Detail_Info = new List <Sale_Detail_Info>(); foreach (Product_Info item in c_list_Product_Buy) { Sale_Detail_Info _Sale_Detail_Info = new Sale_Detail_Info(); _Sale_Detail_Info.Product_Id = item.Product_Id; _Sale_Detail_Info.Status = Convert.ToInt16(Status_Type.DaBan); _Sale_Detail_Info.Count = Convert.ToInt16(item.Count_Sale_By_Header); _Sale_Detail_Info.Color_Id = Convert.ToInt16(item.Color_Id); p_Sale_Detail_Info.Add(_Sale_Detail_Info); } return(_Sale_Header_Info); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); return(null); } }
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()); } }
void Print() { try { Sale_Header_Info _Sale_Header_Info = (Sale_Header_Info)dgrSaleHeader.SelectedItem; if (_Sale_Header_Info == null) { return; } List <Product_Info> _list_Product_Buy = c_Product_Controller.Get_Product_By_Sale_Header(_Sale_Header_Info.SoHoaDon); #region Kết xuất FlexCel.Report.FlexCelReport flcReport = new FlexCel.Report.FlexCelReport(); string _path = CommonData.ExcelDesignFilePath; string _fileExcelName = "Hoa_Don_Ban_Buon.xls"; DataSet ds_all = new DataSet(); DataTable _dt = ConvertData.ConvertToDatatable(_list_Product_Buy); _dt.Columns.Add("STT"); int index = 1; foreach (DataRow item in _dt.Rows) { item["STT"] = index; index++; } ds_all.Tables.Add(_dt); ds_all.Tables[0].TableName = "BanBuon"; if (ds_all.Tables.Count <= 0) { Mouse.OverrideCursor = null; NoteBox.Show("Không có dữ liệu để kết xuất", "Thông báo", NoteBoxLevel.Note); return; } if (ds_all.Tables[0].Rows.Count <= 0) { Mouse.OverrideCursor = null; NoteBox.Show("Không có dữ liệu để kết xuất", "Thông báo", NoteBoxLevel.Note); return; } _path += _fileExcelName; CommonFunction.SetValueExportByDataTable(ref flcReport, ds_all); CommonFunction.SetValueExportByString(ref flcReport, "SoHoaDon", _Sale_Header_Info.SoHoaDon); CommonFunction.SetValueExportByString(ref flcReport, "Customer", _Sale_Header_Info.Customer_Name); CommonFunction.SetValueExportByString(ref flcReport, "Address", _Sale_Header_Info.Address); string _tienBangChu = ConvertData.ConvertMoneyToStr(Convert.ToDouble(_Sale_Header_Info.Total_Amount)); CommonFunction.SetValueExportByString(ref flcReport, "TienBangChu", _tienBangChu); System.Windows.Forms.SaveFileDialog saveReport = new System.Windows.Forms.SaveFileDialog(); saveReport.Filter = "Excel files (*.xls)|*.xls"; if (saveReport.ShowDialog() == System.Windows.Forms.DialogResult.OK) { CommonFunction.ExportExcel(flcReport, _path, saveReport); } #endregion } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
public bool Sale_Header_Insert(Sale_Header_Info p_Sale_Header_Info, ref decimal _id) { try { SqlParameter[] spParameter = new SqlParameter[16]; int i = 0; spParameter[i] = new SqlParameter("@Customer_Id", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Customer_Id; i++; spParameter[i] = new SqlParameter("@BranchId", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.BranchId; i++; spParameter[i] = new SqlParameter("@Sale_Date", SqlDbType.DateTime); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Sale_Date; i++; spParameter[i] = new SqlParameter("@SalesType", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.SalesType; i++; spParameter[i] = new SqlParameter("@Total_Amount", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Total_Amount; i++; spParameter[i] = new SqlParameter("@Debt_Amount", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Debt_Amount; i++; spParameter[i] = new SqlParameter("@UserName", SqlDbType.NVarChar); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.UserName; i++; spParameter[i] = new SqlParameter("@CreatedDate", SqlDbType.DateTime); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.CreatedDate; i++; spParameter[i] = new SqlParameter("@Comment", SqlDbType.NVarChar); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Comment; i++; spParameter[i] = new SqlParameter("@SoHoaDon", SqlDbType.NVarChar); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.SoHoaDon; i++; spParameter[i] = new SqlParameter("@Ship_Price", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Ship_Price; i++; spParameter[i] = new SqlParameter("@Per_Discont", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Per_Discont; i++; spParameter[i] = new SqlParameter("@Discount", SqlDbType.Decimal); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Discount; i++; spParameter[i] = new SqlParameter("@Pay_Type", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Pay_Type; i++; spParameter[i] = new SqlParameter("@Per_Discount_Price", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Input; spParameter[i].Value = p_Sale_Header_Info.Per_Discount_Price; i++; spParameter[i] = new SqlParameter("@Sale_Header_Id", SqlDbType.Int); spParameter[i].Direction = ParameterDirection.Output; spParameter[i].Value = _id; SqlHelper.ExecuteNonQuery(CommonData.ConnectionString, CommandType.StoredProcedure, "proc_Sale_Header_Insert", spParameter); _id = Convert.ToDecimal(spParameter[i].Value); return(true); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); return(false); } }