Skip to content

Commit

Permalink
fix: Create constructor with Inter property
Browse files Browse the repository at this point in the history
  • Loading branch information
Hibino02 committed May 11, 2024
1 parent 608aeb0 commit e43baec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
18 changes: 10 additions & 8 deletions WHIO/Model/Inbound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void getquantityofproductlist()
conn.Close();
}
}
public Inbound(string invoiceNo, DateTime deliveryDate, Supplier supplier, Storage storage) : base(invoiceNo, deliveryDate, supplier)
public Inbound(string invoiceNo, DateTime deliveryDate, Supplier supplier, Storage storage, bool isinter) : base(invoiceNo, deliveryDate, supplier, isinter)
{
this.storage = storage;
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public static List<Inbound> GetInboundList()
return inboundList;
}

public override bool Change()
public override bool Create()
{
MySqlConnection conn = null;
try
Expand All @@ -130,13 +130,13 @@ public override bool Change()
conn.Open();
using (var cmd = conn.CreateCommand())
{
string update = $"UPDATE inbound SET InvoiceNo = @invoice, DeliveryDate = @date, SupplierID = @sup, StorageID = @sto WHERE ID = @id ";
cmd.CommandText = update;
string insert = $"INSERT INTO inbound (ID, InvoiceNo, DeliveryDate, SupplierID, StorageID, IsInter) VALUES (NULL, @invoice, @date, @sup, @sto, @isinter)";
cmd.CommandText = insert;
cmd.Parameters.AddWithValue("@invoice", InvoiceNo);
cmd.Parameters.AddWithValue("@date", DeliveryDate);
cmd.Parameters.AddWithValue("@sup", Supplier.ID);
cmd.Parameters.AddWithValue("@sto", Storage.ID);
cmd.Parameters.AddWithValue("@id", ID);
cmd.Parameters.AddWithValue("@isinter", Inter);
cmd.ExecuteNonQuery();
}
return true;
Expand All @@ -152,7 +152,7 @@ public override bool Change()
}
}

public override bool Create()
public override bool Change()
{
MySqlConnection conn = null;
try
Expand All @@ -161,12 +161,14 @@ public override bool Create()
conn.Open();
using (var cmd = conn.CreateCommand())
{
string insert = $"INSERT INTO inbound (ID, InvoiceNo, DeliveryDate, SupplierID, StorageID) VALUES (NULL, @invoice, @date, @sup, @sto)";
cmd.CommandText = insert;
string update = $"UPDATE inbound SET InvoiceNo = @invoice, DeliveryDate = @date, SupplierID = @sup, StorageID = @sto, IsInter = @isinter WHERE ID = @id ";
cmd.CommandText = update;
cmd.Parameters.AddWithValue("@invoice", InvoiceNo);
cmd.Parameters.AddWithValue("@date", DeliveryDate);
cmd.Parameters.AddWithValue("@sup", Supplier.ID);
cmd.Parameters.AddWithValue("@sto", Storage.ID);
cmd.Parameters.AddWithValue("@isinter", Inter);
cmd.Parameters.AddWithValue("@id", ID);
cmd.ExecuteNonQuery();
}
return true;
Expand Down
8 changes: 5 additions & 3 deletions WHIO/Model/Outbound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void getdeliveryplacelist()
conn.Close();
}
}
public Outbound(string invoiceNo, DateTime deliveryDate, Supplier supplier) : base(invoiceNo, deliveryDate, supplier) { }
public Outbound(string invoiceNo, DateTime deliveryDate, Supplier supplier, bool isinter) : base(invoiceNo, deliveryDate, supplier, isinter) { }

//Method only for Outbound (not in Transport)
public static List<Outbound> GetOutboundList()
Expand Down Expand Up @@ -160,11 +160,12 @@ public override bool Create()
conn.Open();
using (var cmd = conn.CreateCommand())
{
string insert = $"INSERT INTO outbound (ID, InvoiceNo, DeliveryDate, SupplierID) VALUES (NULL, @invoice, @date, @sup)";
string insert = $"INSERT INTO outbound (ID, InvoiceNo, DeliveryDate, SupplierID, IsInter) VALUES (NULL, @invoice, @date, @sup, @isinter)";
cmd.CommandText = insert;
cmd.Parameters.AddWithValue("@invoice", InvoiceNo);
cmd.Parameters.AddWithValue("@date", DeliveryDate);
cmd.Parameters.AddWithValue("@sup", Supplier.ID);
cmd.Parameters.AddWithValue("@isinter", Inter);
cmd.ExecuteNonQuery();
}
return true;
Expand All @@ -189,11 +190,12 @@ public override bool Change()
conn.Open();
using (var cmd = conn.CreateCommand())
{
string update = $"UPDATE outbound SET InvoiceNo = @invoice, DeliveryDate = @date, SupplierID = @sup WHERE ID = @id ";
string update = $"UPDATE outbound SET InvoiceNo = @invoice, DeliveryDate = @date, SupplierID = @sup, IsInter = @isinter WHERE ID = @id ";
cmd.CommandText = update;
cmd.Parameters.AddWithValue("@invoice", InvoiceNo);
cmd.Parameters.AddWithValue("@date", DeliveryDate);
cmd.Parameters.AddWithValue("@sup", Supplier.ID);
cmd.Parameters.AddWithValue("@isinter", Inter);
cmd.Parameters.AddWithValue("@id", ID);
cmd.ExecuteNonQuery();
}
Expand Down
4 changes: 3 additions & 1 deletion WHIO/Model/Transport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void CheckAndUpdateField(string value)
invoiceno = reader["InvoiceNo"].ToString();
deliverydate = reader.GetDateTime(reader.GetOrdinal("DeliveryDate"));
supplier = new Supplier(Convert.ToInt32(reader["SupplierID"]));
inter = reader.GetBoolean("IsInter");
}
}
}
Expand All @@ -73,13 +74,14 @@ public Transport(int id)
truckquantitypershipmentlist = new Dictionary<Truck, int>(new TruckEqualityComparer());
CheckAndUpdateField(id.ToString());
}
public Transport(string invoiceNo,DateTime deliveryDate,Supplier supplier)
public Transport(string invoiceNo,DateTime deliveryDate,Supplier supplier,bool isinter)
{
quantityofproductlist = new Dictionary<Product, int>(new ProductEqualityComparer());
truckquantitypershipmentlist = new Dictionary<Truck, int>(new TruckEqualityComparer());
invoiceno = invoiceNo;
deliverydate = deliveryDate;
this.supplier = supplier;
this.inter = isinter;
}

public abstract bool Create();
Expand Down

0 comments on commit e43baec

Please sign in to comment.