private void button1_Click(object sender, EventArgs e) { PUYOWAREHOUSEDataContext a = new PUYOWAREHOUSEDataContext(); string Master_Transaction_ID; var Get_Last_Master_Transaction = from Master_Transaction in a.Warehouse_Master_Transactions orderby Master_Transaction.Master_Transaction_ID descending select Master_Transaction.Master_Transaction_ID; int Count_Master_Transaction = Get_Last_Master_Transaction.Count(); if (Count_Master_Transaction == 0) { Master_Transaction_ID = "MT00001"; } else { var Get_Last_Master_Transaction_ID = Get_Last_Master_Transaction.First().ToString(); string New_Master_Transaction_ID = PUYO_FUNCTION.ID_PADDING(Get_Last_Master_Transaction_ID); Master_Transaction_ID = New_Master_Transaction_ID; } DateTime Now_Date = DateTime.Now; Warehouse_Master_Transaction New_Master_Transaction = new Warehouse_Master_Transaction(); New_Master_Transaction.Master_Transaction_ID = Master_Transaction_ID; New_Master_Transaction.Master_Transaction_Date = Now_Date; //This will change depending on the ID of the cashier New_Master_Transaction.Store_ID = Store_Combo.Text; a.Warehouse_Master_Transactions.InsertOnSubmit(New_Master_Transaction); a.SubmitChanges(); int Data_Row_Number = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { Warehouse_Transaction New_Transaction = new Warehouse_Transaction(); //This is the data of the name of the product string Product_ID_Single = (dataGridView1.Rows[Data_Row_Number].Cells[3].Value).ToString(); //This is the data of the price of the product var Get_Product_Id = from Product_Get in a.Warehouse_Products where Product_Get.Product_ID.Equals(Product_ID_Single) select Product_Get.Product_ID; string Price_Single = Get_Product_Id.First().ToString(); //This is the data of the quantity of the product string Product_Quantity_Single = (dataGridView1.Rows[Data_Row_Number].Cells[4].Value).ToString(); //This is the data of the total price of the product string Total_Price_Single = (dataGridView1.Rows[Data_Row_Number].Cells[5].Value).ToString(); //This is the data of the status of the product string Status_Single = (dataGridView1.Rows[Data_Row_Number].Cells[6].Value.ToString()); string Transaction_ID; var Get_Last_Transaction = from Transaction in a.Warehouse_Transactions orderby Transaction.Transaction_ID descending select Transaction.Transaction_ID; int Count_Transaction = Get_Last_Transaction.Count(); if (Count_Transaction == 0) { Transaction_ID = "TI00001"; } else { var Get_Last_Transaction_ID = Get_Last_Transaction.First().ToString(); string New_Transaction_ID = PUYO_FUNCTION.ID_PADDING(Get_Last_Transaction_ID); Transaction_ID = New_Transaction_ID; } New_Transaction.Master_Transaction_ID = Master_Transaction_ID; New_Transaction.Product_ID = Product_ID_Single; New_Transaction.Quantity = Convert.ToInt32(Product_Quantity_Single); New_Transaction.Transaction_ID = Transaction_ID; New_Transaction.Total_Price = Convert.ToInt32(Total_Price_Single); New_Transaction.Status = Status_Single; a.Warehouse_Transactions.InsertOnSubmit(New_Transaction); a.SubmitChanges(); Data_Row_Number += 1; } MessageBox.Show("Data Successfully Sent To Warehouse", "Info", MessageBoxButtons.OK, MessageBoxIcon.None); }
partial void DeleteWarehouse_Master_Transaction(Warehouse_Master_Transaction instance);
private void detach_Warehouse_Master_Transactions(Warehouse_Master_Transaction entity) { this.SendPropertyChanging(); entity.Warehouse_Store = null; }
partial void InsertWarehouse_Master_Transaction(Warehouse_Master_Transaction instance);