Question

In: Computer Science

Let’s say you have a light shop where you sale and purchase having different types of...

Let’s say you have a light shop where you sale and purchase having different types of light and different electric appliances. Now using principles of OOP I want you want make an OOP program which can cater the aforementioned problem.(show different types of purchase and sales )

C#

Solutions

Expert Solution

public List<PurchaseOrder> Save(PurchaseOrder po)

{

List<PurchaseOrder> poList = InitialData();

po.PoNumber = "PO010003";

poList.Add(po);

return poList;

}

public ActionResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ProductViewModel> products)

{

if (products != null && this.ModelState.IsValid)

{

var purchaseOrder = new PurchaseOrder()

{

DateOfOrder = DateTime.Now,

DateOfDelivery = DateTime.Now.AddDays(2),

ClientId = this.UserProfile.OrganizationId ?? 0,

SupplierId = products.FirstOrDefault().SupplierId,

CreatorId = this.UserProfile.Id

};

this.PurchaseOrders.Add(purchaseOrder);

var order = products.Select(product => new OrderQuantity()

{

ProductId = product.Id, PurchaseOrderId = purchaseOrder.Id, Quantity = product.Quantities

}).ToList();

this.OrderQuantities.Add(order);

this.AddToastMessage("Succefull", "You made order !", ToastType.Success);

return this.Redirect("/Private/Orders/All");

}

this.AddToastMessage("Error!", string.Empty, ToastType.Error);

return this.Json(products.ToDataSourceResult(request, this.ModelState));

}

public static Batch CreateOrders2()

{

var b = new Batch();

var o = new PurchaseOrder();

o.CustId = "001";

var i = new light();

i.ProdId = "111";

i.Price = 500;

i.Quantity = 1;

o.Item.Add(i);

i = new fan();

i.ProdId = "222";

i.Price = 150;

i.Quantity = 3;

o.light.Add(i);

o.fan.Add(i);

b.PurchaseOrder.Add(o);

o = new PurchaseOrder();

o.CustId = "002";

i = new cooker();

i.ProdId = "333";

i.Price = 250;

i.Quantity = 1;

b.PurchaseOrder.Add(o);

return b;

}

protected void btnSave_Click(object sender, EventArgs e)

{

PurchaseOrderModule module = new PurchaseOrderModule();

PurchaseOrder purchaseOrder = new PurchaseOrder();

try

{

purchaseOrder.CustomerId = Convert.ToInt32(ddlCustomers.SelectedValue);

purchaseOrder.PONo = txtPONo.Text;

purchaseOrder.Price = Convert.ToDecimal(txtPrice.Text);

purchaseOrder.CreatedBy = txtCreatedBy.Text;

purchaseOrder.DateCreated = Convert.ToDateTime(txtDateCreated.Text);

purchaseOrder.DeliveryDateTime = Convert.ToDateTime(txtDeliveryDate.Text);

purchaseOrder.Quantity = Convert.ToInt32(txtQuantity.Text);

purchaseOrder.Remarks = txtRemarks.Text;

purchaseOrder.Status = Convert.ToInt32(ddlStatus.SelectedValue);

purchaseOrder.TotalPrice = Convert.ToDecimal(txtTotalPrice.Text);

if (ViewState["id"] != null)

purchaseOrder.Id = Convert.ToInt32(ViewState["id"]);

module.Save(purchaseOrder);

Response.Redirect("~/PurchasedOrder.aspx");

//lblCustomer.Text = ddlCustomers.SelectedValue;

//Helper.EnableControls(false, Helper.GetControlsInPlaceHolder("InfoPlaceHolder", Master));

}

catch (Exception ex)

{

lblError.Text = "Please contact administrator. Error message : " + ex.Message;

}

}

public PurchaseOrder Add(PurchaseOrder order)

{

this.orders.Add(order);

this.orders.Save();

return order;

public CheckoutDetailsVM(PurchaseOrder p, string FullName, string Email, string BillingAddress, string ShippingAddress)

{

this.LastOrder = p;

this.FullName = FullName;

this.Email = Email;

this.BillingAddress = BillingAddress;

this.ShippingAddress = ShippingAddress;

}

public void CreateUpdateCustomer(PurchaseOrder order, IIdentity identity)

{

// try catch so this does not interrupt the order process.

try

{

var billingAddress = order.OrderAddresses.FirstOrDefault(x => x.Name == Constants.Order.BillingAddressName);

var shippingAddress = order.OrderAddresses.FirstOrDefault(x => x.Name == Constants.Order.ShippingAddressName);

MembershipUser user = null;

if (!identity.IsAuthenticated)

{

string email = null;

if (billingAddress != null)

{

email = billingAddress.Email.Trim();

user = Membership.GetUser(email);

}

if (user == null)

{

var customer = CreateCustomer(email, Guid.NewGuid().ToString(), billingAddress.DaytimePhoneNumber, billingAddress, shippingAddress, false,

createStatus => Log.Error("Failed to create user during order completion. " + createStatus.ToString()));

if (customer != null)

{

order.CustomerId = Guid.Parse(customer.PrimaryKeyId.Value.ToString());

order.CustomerName = customer.FirstName + " " + customer.LastName;

order.AcceptChanges(); SetExtraCustomerProperties(order, customer); _emailService.SendWelcomeEmail(billingAddress.Email);

}

}

else

{

var customer = CustomerContext.Current.GetContactForUser(user);

order.CustomerName = customer.FirstName + " " + customer.LastName;

order.CustomerId = Guid.Parse(customer.PrimaryKeyId.Value.ToString());

order.AcceptChanges();

SetExtraCustomerProperties(order, customer);

}

}

else

{

user = Membership.GetUser(identity.Name);

var customer = CustomerContext.Current.GetContactForUser(user);

SetExtraCustomerProperties(order, customer);

}

}

catch (Exception ex)

{

// Log here

Log.Error("Error during creating / update user", ex);

}

}

private void Create(string filename)

{

XmlSerializer ser=new XmlSerializer(typeof(PurchaseOrder));

PurchaseOrder po=new PurchaseOrder();

Address addr=new Address();

addr.FirstName="xxxx";

po.MyAddress=addr;

TextWriter writer=new StreamWriter(filename);

ser.Serialize(writer, po);

writer.Close();

}

private void Create(string filename)

{

XmlSerializer ser=new XmlSerializer(typeof(PurchaseOrder));

PurchaseOrder po=new PurchaseOrder();

Light item1=new Light("Philips", (decimal)500.2);

Fan item2=new Fan("Usha", (decimal)150.4);

Cooker item3=new Cooker("Prestige",(decimal)250.33)

po.ItemsOrdered=new Light[1];

po.ItemsOrdered=new Fan[3];

po.ItemsOrdered=new Cooker [1];

po.ItemsOrdered[0]=item1;

po.ItemsOrdered[1]=item2;

TextWriter writer=new StreamWriter(filename);

ser.Serialize(writer, po);

writer.Close();

}


Related Solutions

: Let’s say we are working with shapes having different types like 2d, 3D and so...
: Let’s say we are working with shapes having different types like 2d, 3D and so on. Using private access to fields of class design a class for rectangle.     c# for both 2d and 3d rectangle
Ann is planning to purchase some items. The store is having a sale, where if you...
Ann is planning to purchase some items. The store is having a sale, where if you buy one item the 2nd item (of equal or lower value) is 50% off. The tax on each item is 7%.                                                                                                                     Item 1 costs $39.75 before taxes. Item 2 costs $65.50 before taxes. If Ann only buys Item 2, what is the total cost of her purchase after taxes? Display this value (rounded to the nearest cent) with a suitable message. If...
So let’s say you have a beaker that contains 6.02g ammonium chloride and to this you...
So let’s say you have a beaker that contains 6.02g ammonium chloride and to this you add 300.0mL of 0.450 M calcium hydroxide according to the following chemical equation: Ca(OH)2(aq) + 2NH4Cl(s)  CaCl2(aq) + 2H2O(l) + 2NH3(g) H = +90.66 kJ A) draw the beaker at the end of the reaction- what would be in the beaker and or around it. what would the products look like on a molecular/atom/ion level? B) at STP, how many L of your...
So let’s say you have a beaker that contains 78.8g of ammonium carbonate and to this...
So let’s say you have a beaker that contains 78.8g of ammonium carbonate and to this you add 175 mL of 5.80 M hydrochloric acid according to the following chemical equation: 2HCl(aq) + (NH4)2CO3(s) -- > 2NH4Cl(aq) + H2O(l) + CO2(g) .DeltaH = -145 kJ A) Draw the beaker at the end of the reaction - what would e in the beaker and/or around it. What would the products look like on a molecular/atom/ion level? B) Why would water vapor...
Let’s say you have the ciphertext for the given plaintext. Plaintext: it was disclosed yesterday that...
Let’s say you have the ciphertext for the given plaintext. Plaintext: it was disclosed yesterday that several informal but direct contacts have been made with political representatives of the viet cong in Moscow Ciphertext: UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZVUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSXEPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ Can you determine the cipher used? If yes, name the cipher. Explain why. Can you determine all/part of the key. If yes, give the key or part of the key. Explain how you deduced it.
Q: Let’s say you have an unordered list of numbers and you wanted to put them...
Q: Let’s say you have an unordered list of numbers and you wanted to put them in order from lowest to highest value. How would you do that? You’re probably thinking that you would just look at all the numbers, find the lowest number and put it at the beginning of your list. Then you would find the next largest number and put it in the second spot in the list, and so on until you’ve ordered the entire list...
So let’s say you have a beaker that contains 15.2 g sodium sulfite and to this...
So let’s say you have a beaker that contains 15.2 g sodium sulfite and to this you add 150. mL of 1.25 M nitric acid according to the following chemical equation: Na2SO3(s) + 2HNO3 (aq)  2NaNO3 (aq)+ H2O(l) + SO2 (g)   H = -225. kJ A). Draw the beaker at the end of the reaction. What would e in the beaker and/or around it. What would the products look like on a molecular/atom/ion level? B). At STP, how many...
Let’s say you wanted to have a communications satellite orbit the Moon so that it stayed...
Let’s say you wanted to have a communications satellite orbit the Moon so that it stayed exactly above one point of the Moon’s equator (similar to a geosynchronous here on Earth). What would the linear speed and lunar altitude of your communications satellite be?
Let’s say a very light magnetic point brush and a uniform magnetic field generator are readily...
Let’s say a very light magnetic point brush and a uniform magnetic field generator are readily available. Design the apparatus in way that a user may opt to draw small perfect circles, or big circles. No idea how to do this as i am just starting in physics. thank you Say you want to build a painting apparatus that draws a perfect circle. Lets say a very ligjt magnectic brush and uniform magnetic field generator are readily available. Desigm the...
Let’s say that a firm has given itself the ‘green light’ to build factory #5. What...
Let’s say that a firm has given itself the ‘green light’ to build factory #5. What forces will determine whether this firm will OBTAIN FINANCING for the factory? (in class we discussed a sum of $100 million) 2. Why may some firms DELAY previously planned construction projects in the next year? 3. In theory, what forces may influence a firm to build factory #5 in a country outside the U.S.? 4. What forces may influence a firm to build factory...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT