// GET: Quorte public ActionResult Create() { OrderAndInvoiceModel DropdownList = new OrderAndInvoiceModel() { ShippingMethodList = GetShippingMethodList(), PaymentTermsList = GetPaymentTermsList(), FreightTermsList = GetFreightTermsList(), CurrencyList = GetCurrencyList() }; return(View(DropdownList)); }
//index public ActionResult OrderAndInvoiceIxdex() { List <OrderAndInvoiceModel> OrderAndInvoiceList = new List <OrderAndInvoiceModel>(); string Dbconnection = ConfigurationManager.ConnectionStrings["LeadConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(Dbconnection)) { con.Open(); SqlCommand Com = new SqlCommand("SP_Order_Invoice_SelectAll", con); Com.CommandType = CommandType.StoredProcedure; SqlDataReader Sqlreader = Com.ExecuteReader(); while (Sqlreader.Read()) { var customer = new OrderAndInvoiceModel(); //customer.QuoteId = Convert.ToInt32(Sqlreader["QuoteId"]); customer.Name = Sqlreader["Name"].ToString(); customer.Currency = Sqlreader["Currency"].ToString(); customer.Opportunity = Sqlreader["Opportunity"].ToString(); customer.PotentialCustomer = Sqlreader["PotentialCustomer"].ToString(); customer.PriceList = Sqlreader["PriceList"].ToString(); customer.RequestedDelivery = Convert.ToDateTime(Sqlreader["RequestedDelivery"]); customer.DateFullfilled = Convert.ToDateTime(Sqlreader["DateFullfill"]); customer.Description = Sqlreader["Description"].ToString(); customer.PaymentTerms = Sqlreader["PaymentTerms"].ToString(); customer.FreightTerms = Sqlreader["FrieghtTerms"].ToString(); customer.BillToStreet = Sqlreader["BillToStreet"].ToString(); customer.BillToState = Sqlreader["Country"].ToString(); customer.BillToCountry = Sqlreader["BillToCountry"].ToString(); customer.BillingPostalCode = Sqlreader["BillingPostalCode"].ToString(); customer.ShippingMethod = Sqlreader["ShippingMethod"].ToString(); customer.ShipToStreet = Sqlreader["ShipToStreet"].ToString(); customer.ShipToCity = Sqlreader["ShipToCity"].ToString(); customer.ShipToState = Sqlreader["ShipToState"].ToString(); customer.ShipToCountry = Sqlreader["ShipToCountry"].ToString(); customer.ShipingPostalCodes = Convert.ToInt32(Sqlreader["ShipingPostalCode"]); OrderAndInvoiceList.Add(customer); } return(View(OrderAndInvoiceList)); } }
public ActionResult Create(OrderAndInvoiceModel model) { OrderAndInvoiceModel DropdownList = new OrderAndInvoiceModel() { ShippingMethodList = GetShippingMethodList(), PaymentTermsList = GetPaymentTermsList(), FreightTermsList = GetFreightTermsList(), CurrencyList = GetCurrencyList() }; { CONNECTION(); SqlCommand Command = new SqlCommand("SP_OrderInvoice_Insert", con); Command.CommandType = CommandType.StoredProcedure; con.Open(); Command.Parameters.AddWithValue("@RefOrder_InvoiceId", model.RefOrder_InvoiceId); Command.Parameters.AddWithValue("@Name", model.Name); Command.Parameters.AddWithValue("@EmailId", model.EmailId); Command.Parameters.AddWithValue("@Currency", model.Currency); Command.Parameters.AddWithValue("@Opportunity", model.Opportunity); Command.Parameters.AddWithValue("@PotentialCustomer", model.PotentialCustomer); Command.Parameters.AddWithValue("@PriceList", model.PriceList); Command.Parameters.AddWithValue("@PriceLocked", model.PriceLocked); Command.Parameters.AddWithValue("@RequestedDelivery", model.RequestedDelivery); Command.Parameters.AddWithValue("@DateFullfilled", model.DateFullfilled); Command.Parameters.AddWithValue("@ShippingMethod", model.ShippingMethod); Command.Parameters.AddWithValue("@PaymentTerms", model.PaymentTerms); Command.Parameters.AddWithValue("@FreightTerms", model.FreightTerms); Command.Parameters.AddWithValue("@BillToStreet", model.BillToStreet); Command.Parameters.AddWithValue("@BillToState", model.BillToState); Command.Parameters.AddWithValue("@BillToCity", model.BillToCity); Command.Parameters.AddWithValue("@BillToCountry", model.BillToCountry); Command.Parameters.AddWithValue("@BillingPostalCode", model.BillingPostalCode); Command.Parameters.AddWithValue("@ShipToStreet", model.ShipToStreet); Command.Parameters.AddWithValue("@ShipToState", model.ShipToState); Command.Parameters.AddWithValue("@ShipToCity", model.ShipToCity); Command.Parameters.AddWithValue("@ShipToCountry", model.ShipToCountry); Command.Parameters.AddWithValue("@ShipingPostalCodes", model.ShipingPostalCodes); Command.Parameters.AddWithValue("@Description", model.Description); Command.ExecuteNonQuery(); ViewBag.Message = "ORDERS & INVOICE CREATE SUCCESSFULLY :)"; SmtpSection section = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); string to = model.EmailId; string from = section.From; int index = to.IndexOf('@'); string name = to.Substring(0, index); MailMessage message = new MailMessage(from, to); message.Subject = "Successful Order Created"; message.Body = "Hi " + name + " , your Product have been Orderd Successfully!!! And your Order Id is" + model.RefOrder_InvoiceId + " and Request Devivery Date is " + model.RequestedDelivery; SmtpClient smtp = new SmtpClient(); smtp.Port = section.Network.Port; smtp.EnableSsl = section.Network.EnableSsl; smtp.UseDefaultCredentials = true; smtp.Credentials = new NetworkCredential(section.Network.UserName, section.Network.Password); smtp.Host = section.Network.Host; smtp.Send(message); con.Close(); return(View(DropdownList)); } }