//InSertAllInputDetail private int InSertAllInputHistory(DataTable tb_inputhistory) { int result = 0; foreach (DataRow datarow in tb_inputhistory.Rows) { if (datarow[0].ToString() != "") { EC_tb_InputHistory ec_tb_inputhistory = new EC_tb_InputHistory(); ec_tb_inputhistory.InputID = Convert.ToInt32(datarow[0].ToString()); ec_tb_inputhistory.ProductID = Convert.ToInt32(datarow[1].ToString()); ec_tb_inputhistory.InputDate = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[2].ToString()); ec_tb_inputhistory.UserID = Convert.ToInt32(datarow[3].ToString()); ec_tb_inputhistory.UserName = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[4].ToString()); ec_tb_inputhistory.Cost = Convert.ToDecimal(datarow[5].ToString()); ec_tb_inputhistory.Price = Convert.ToDecimal(datarow[6].ToString()); ec_tb_inputhistory.InventoryCount = Convert.ToInt32(datarow[7].ToString()); ec_tb_inputhistory.CategoryID = Convert.ToInt32(datarow[8].ToString()); ec_tb_inputhistory.Tax = Convert.ToInt32(datarow[9].ToString()); ec_tb_inputhistory.Active = Convert.ToInt32(datarow[10].ToString()); ec_tb_inputhistory.Country = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[11].ToString()); ec_tb_inputhistory.SizeWeight = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[12].ToString()); if (bus_tb_inputhistory.InsertInputHistory(ec_tb_inputhistory, StaticClass.GeneralClass.flag_database_type_general) == 1) { result++; } } } return(result); }
//muiBtnOK_Click private void muiBtnOK_Click(object sender, RoutedEventArgs e) { try { var product = CheckInput(); if (product != null) { if (bus_tb_product.InsertProduct(product, StaticClass.GeneralClass.flag_database_type_general) == 1) { if (!System.IO.Directory.Exists(current_directory + @"\images")) { System.IO.Directory.CreateDirectory(current_directory + @"\images"); } if (path_image != "") { System.IO.File.Copy(path_image, current_directory + @"\images\" + (product.ProductID).ToString() + @".png", true); } //insert history EC_tb_InputHistory history = new EC_tb_InputHistory(); history.ProductID = product.ProductID; history.ProductName = product.ShortName; history.InputDate = System.DateTime.Now.ToString(); history.UserID = StaticClass.GeneralClass.id_user_general; history.UserName = StaticClass.GeneralClass.name_user_general; history.Cost = product.Cost; history.Price = product.Price; history.InventoryCount = product.InventoryCount; history.CategoryID = product.CategoryID; history.CategoryName = StaticClass.GeneralClass.HandlingSpecialCharacter(category_name); history.Tax = product.Tax; history.Active = product.Active; history.Country = product.Country; history.SizeWeight = product.SizeWeight; bus_tb_input_history.InsertInputHistory(history, StaticClass.GeneralClass.flag_database_type_general); if (muibtnadd_delegate != null) { StaticClass.GeneralClass.flag_add_edit_delete_product_general = true; muibtnadd_delegate(true); this.Close(); } } } } catch (Exception ex) { tblNotification.Text = ex.Message; } }
//GetListInputHistory private void GetListInputHistory(int productid, int categoryid) { list_ec_tb_inputhistory.Clear(); string condition = ""; if ((productid == 0) && (categoryid != 0)) { condition = "where CategoryID = " + categoryid + " and ProductName like '%" + product_name + "%' "; } if ((productid != 0) && categoryid == 0) { condition = "where ProductID = " + productid; } DataTable tb_input_history = new DataTable(); tb_input_history = bus_tb_input_history.GetInputHistory(condition); int no = 0; foreach (DataRow dr in tb_input_history.Rows) { no++; EC_tb_InputHistory _inputHistory = new EC_tb_InputHistory(); _inputHistory.No = no; _inputHistory.InputID = Convert.ToInt32(dr["InputID"].ToString()); _inputHistory.ProductID = Convert.ToInt32(dr["ProductID"].ToString()); _inputHistory.ProductName = dr["ProductName"].ToString(); _inputHistory.InputDate = dr["InputDate"].ToString(); _inputHistory.UserID = Convert.ToInt32(dr["UserID"].ToString()); _inputHistory.UserName = dr["UserName"].ToString(); _inputHistory.Cost = Convert.ToDecimal(dr["Cost"].ToString()); _inputHistory.StrCost = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(_inputHistory.Cost); _inputHistory.Price = Convert.ToDecimal(dr["Price"].ToString()); _inputHistory.StrPrice = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(_inputHistory.Price); _inputHistory.InventoryCount = Convert.ToInt32(dr["InventoryCount"].ToString()); _inputHistory.CategoryID = Convert.ToInt32(dr["CategoryID"].ToString()); _inputHistory.CategoryName = dr["CategoryName"].ToString(); _inputHistory.Tax = Convert.ToInt32(dr["Tax"].ToString()); _inputHistory.Country = dr["Country"].ToString(); _inputHistory.SizeWeight = dr["Size_Weight"].ToString(); _inputHistory.Currency = StaticClass.GeneralClass.currency_setting_general; list_ec_tb_inputhistory.Add(_inputHistory); } }
//InsertInputHistory public int InsertInputHistory(EC_tb_InputHistory ec_tb_inputhistory, bool data_type) { string sql = ""; if (!data_type) { sql = "INSERT INTO [tb_InputHistory]([ProductID], [ProductName], [InputDate], [UserID], [UserName], [Cost], [Price], [InventoryCount], [CategoryID], [CategoryName], [Tax], [Active], [Country], [Size_Weight]) VALUES(" + ec_tb_inputhistory.ProductID + ", '" + ec_tb_inputhistory.ProductName + "', '" + ec_tb_inputhistory.InputDate + "', " + ec_tb_inputhistory.UserID + ", '" + ec_tb_inputhistory.UserName + "', " + ec_tb_inputhistory.Cost.ToString(new CultureInfo("en-US")) + ", " + ec_tb_inputhistory.Price.ToString(new CultureInfo("en-US")) + ", " + ec_tb_inputhistory.InventoryCount + "," + ec_tb_inputhistory.CategoryID + ", '" + ec_tb_inputhistory.CategoryName + "', " + ec_tb_inputhistory.Tax + ", " + ec_tb_inputhistory.Active + ", '" + ec_tb_inputhistory.Country + "', '" + ec_tb_inputhistory.SizeWeight + "')"; } else { sql = "INSERT INTO [tb_InputHistory]([ProductID], [ProductName], [InputDate], [UserID], [UserName], [Cost], [Price], [InventoryCount], [CategoryID], [CategoryName], [Tax], [Active], [Country], [Size_Weight]) VALUES(" + ec_tb_inputhistory.ProductID + ", N'" + ec_tb_inputhistory.ProductName + "', N'" + ec_tb_inputhistory.InputDate + "', " + ec_tb_inputhistory.UserID + ", N'" + ec_tb_inputhistory.UserName + "', " + ec_tb_inputhistory.Cost.ToString(new CultureInfo("en-US")) + ", " + ec_tb_inputhistory.Price.ToString(new CultureInfo("en-US")) + ", " + ec_tb_inputhistory.InventoryCount + "," + ec_tb_inputhistory.CategoryID + ", N'" + ec_tb_inputhistory.CategoryName + "', " + ec_tb_inputhistory.Tax + ", " + ec_tb_inputhistory.Active + ", N'" + ec_tb_inputhistory.Country + "', N'" + ec_tb_inputhistory.SizeWeight + "')"; } return(ConnectionDB.ExecuteNonQuery(sql)); }
//DeleteInputHistory public int DeleteInputHistory(EC_tb_InputHistory ec_tb_inputhistory) { string sql = "DELETE FROM [tb_InputHistory] WHERE [InputID] = " + ec_tb_inputhistory.InputID; return(ConnectionDB.ExecuteNonQuery(sql)); }
//muiBtnOK_Click private void muiBtnOK_Click(object sender, RoutedEventArgs e) { try { CashierRegisterEntity.EC_tb_Product ec_tb_product = CheckInput(); if (ec_tb_product != null) { if (bus_tb_product.UpdateProduct(ec_tb_product, StaticClass.GeneralClass.flag_database_type_general) == 1) { if (path_image != "") { if (!System.IO.Directory.Exists(current_directory + @"\images")) { System.IO.Directory.CreateDirectory(current_directory + @"\images"); } if (path_image != StaticClass.GeneralClass.productpathimage_general) { System.IO.File.Copy(path_image, current_directory + ec_tb_product.PathImage, true); } } if ((barcodeid != txbBarcode.Text.Trim().ToString()) || (short_name != txbShortName.Text.Trim().ToString()) || (long_name != txbLongName.Text.Trim().ToString()) || (cost != txbCost.Text.Trim().ToString()) || (price != txbPrice.Text.Trim().ToString()) || (inventory_count != txbInventoryCount.Text.Trim().ToString()) != (country != txbCountry.Text.Trim().ToString()) || (size_weight != txbSize_Weight.Text.Trim().ToString()) || (tax != chkTax.IsChecked.Value) || (active != chkActive.IsChecked.Value)) { //insert history EC_tb_InputHistory history = new EC_tb_InputHistory(); history.ProductID = ec_tb_product.ProductID; history.ProductName = ec_tb_product.ShortName; history.InputDate = System.DateTime.Now.ToString(); history.UserID = StaticClass.GeneralClass.id_user_general; history.UserName = StaticClass.GeneralClass.name_user_general; history.Cost = ec_tb_product.Cost; history.Price = ec_tb_product.Price; history.InventoryCount = ec_tb_product.InventoryCount; history.CategoryID = ec_tb_product.CategoryID; history.CategoryName = category_name; history.Tax = ec_tb_product.Tax; history.Active = ec_tb_product.Active; history.Country = ec_tb_product.Country; history.SizeWeight = ec_tb_product.SizeWeight; bus_tb_input_history.InsertInputHistory(history, StaticClass.GeneralClass.flag_database_type_general); } if (btnedit_delegate != null) { StaticClass.GeneralClass.flag_add_edit_delete_product_general = true; btnedit_delegate(true); this.Close(); } } } } catch (Exception ex) { tblNotification.Text = ex.Message; } }
//DeleteInputHistory public int DeleteInputHistory(EC_tb_InputHistory ec_tb_inputhistory) { return(sql_tb_inputhistory.DeleteInputHistory(ec_tb_inputhistory)); }
//InsertInputHistory public int InsertInputHistory(EC_tb_InputHistory ec_tb_inputhistory, bool data_type) { return(sql_tb_inputhistory.InsertInputHistory(ec_tb_inputhistory, data_type)); }