private void orderLbl_Click(object sender, EventArgs e) { string content = ""; //if condition is to ensure that the Item list is not empty //string str1 = ""; //str1 += "Item Name< br />"; //str1 += "Quantity < br />"; //str1 += "Price < br />"; if (listOfItems.Count == 0) { // Console.WriteLine("^^^^^^^^^^^^^^^^^^listofItems size={0}",listOfItems.Count); MessageBox.Show("Cart is empty !!"); } else { billNo = generateOrderId(); DateTime dateTime = DateTime.UtcNow.Date; OrderCredentials orderCredentialsRef = new OrderCredentials(billNo, dateTime); OrderCredentialsDAO orderCrDAORef = new OrderCredentialsDAOImpl(); orderCrDAORef.insertOrderCredentials(orderCredentialsRef); BillDAO billDAORef = new BillDAOImpl(); Bill billRef = new Bill(); for (int i = 0; i < listOfItems.Count; i++) { string str = ""; billRef.billNoRef = orderCredentialsRef; billRef.orderId = generateID(); Console.WriteLine("quantity:{0}\n", Convert.ToInt32(listOfItems[i][1])); billRef.quantity = Convert.ToInt32(listOfItems[i][1]); Console.WriteLine("item name:{0}\n", Convert.ToString(listOfItems[i][0])); billRef.selectedItemName = Convert.ToString(listOfItems[i][0]); Console.WriteLine("price:{0}\n", Convert.ToDouble(listOfItems[i][2])); billRef.price = Convert.ToDouble(listOfItems[i][2]); billDAORef.insertBill(billRef); str += billRef.selectedItemName + "  " + "  " + "  "; str += billRef.quantity + " " + " " + " " + " "; str += billRef.price + "  " + " " + " " + " "; content += str + "<br />"; } MessageBox.Show("Order Placed !!"); canecelOrderBtn.Visible = true; listOfItems.Clear(); } // str1 += content; Console.WriteLine(str1); // MessageBox.Show(str1); MessageBox.Show(content); Sendmail(content); }
public List <ArrayList> getorderCredentialsList(OrderCredentials orderCredentialsRef1) { string qry = ""; // List<Items> itemsList = new List<Items>(); ArrayList itemsList = new ArrayList(); DataBaseconnection DbCon = new DataBaseconnection(); if (orderCredentialsRef1 == null) { qry = "select * from dbo.order_orderCredentials"; Console.WriteLine("inside if "); } else { Console.WriteLine("!!!!!!!!!!!!!!!! outside if "); if (orderCredentialsRef1.billNo != 0) { qry = "select * from dbo.order_orderCredentials where billNo= '" + orderCredentialsRef1.billNo + "';"; Console.WriteLine("item name!!!!!!!"); } } SqlConnection cnn = DbCon.ObtainConnection(); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand(qry, cnn); SqlDataReader reader = cmd.ExecuteReader(); OrderCredentials orderCredentialsRef = new OrderCredentials(); List <ArrayList> orderCredList = new List <ArrayList>(); if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("\n\n select * values \n\n"); // itemm.Add(orderCredentialsRef.Itemss(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3),Convert.ToString(reader.GetInt16(4)),Convert.ToString(reader.GetFloat(5)))); // ArrayList arr = orderCredentialsRef.Itemss(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt16(4), reader.GetFloat(5)); Console.WriteLine("******item name:{0}\t item Category:{1}\t item desc:{2} \t item type:{3}\t item stock:{4}\t item unit price:{5}", reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4), reader.GetDouble(5)); orderCredList.Add(orderCredentialsRef.OrderCredentialsList(reader.GetInt32(0), reader.GetDateTime(1))); } } else { Console.WriteLine("No rows found."); } return(orderCredList); }
public void insertOrderCredentials(OrderCredentials orderCredentialsRef) { DataBaseconnection DbCon = new DataBaseconnection(); string qry = "insert into dbo.order_orderCredentials(billNo,OrderDate) values('" + orderCredentialsRef.billNo + "','" + orderCredentialsRef.orderDate + "')"; SqlConnection cnn = DbCon.ObtainConnection(); //MessageBox.Show("Connectiom established !!"); SqlDataAdapter da = new SqlDataAdapter(); // SqlCommand cmd = new SqlCommand(qry, cnn); da.InsertCommand = new SqlCommand(qry, cnn); da.InsertCommand.ExecuteNonQuery(); MessageBox.Show("insert successfull to Order Credentails !!"); cnn.Dispose(); cnn.Close(); }
public void deleteorderCredentials(OrderCredentials orderCredentialsRef) { DataBaseconnection DbCon = new DataBaseconnection(); string qry = "delete from dbo.order_orderCredentials where billNo= '" + orderCredentialsRef.billNo + "';"; SqlConnection cnn = DbCon.ObtainConnection(); // MessageBox.Show("Connectiom established !!"); SqlDataAdapter da = new SqlDataAdapter(); // SqlCommand cmd = new SqlCommand(qry, cnn); da.InsertCommand = new SqlCommand(qry, cnn); da.InsertCommand.ExecuteNonQuery(); MessageBox.Show("delete successfull in order cerdentails!!"); cnn.Dispose(); cnn.Close(); }
public void updateorderCredentials(OrderCredentials orderCredentialsRef) { DataBaseconnection DbCon = new DataBaseconnection(); //if(orderCredentialsRef.description!=null) // string qry = "update dbo.order_item set Description= '" +orderCredentialsRef.description+ "',itemType= '" + orderCredentialsRef.itemType + "' where itemName= '" + orderCredentialsRef.itemName+ "';"; string qry = "update dbo.order_orderCredentials set Description= '" + orderCredentialsRef.orderDate + "' where itemName= '" + orderCredentialsRef.billNo + "';"; SqlConnection cnn = DbCon.ObtainConnection(); // MessageBox.Show("Connectiom established !!"); SqlDataAdapter da = new SqlDataAdapter(); // SqlCommand cmd = new SqlCommand(qry, cnn); da.InsertCommand = new SqlCommand(qry, cnn); da.InsertCommand.ExecuteNonQuery(); MessageBox.Show("update successfull !!"); cnn.Dispose(); cnn.Close(); }
private void button1_Click(object sender, EventArgs e) { Console.WriteLine("Satep1\n"); BillDAO billDAOImpl = new BillDAOImpl(); OrderCredentials o = new OrderCredentials(); o.billNo = billNo; Bill billref = new Bill(); billref.billNoRef = o; Console.WriteLine("Step22"); List <ArrayList> listBill = billDAOImpl.getBillList(billref); for (int i = 0; i < listBill.Count; i++) { Console.WriteLine("Step 3 inside for Loop\t"); billref.orderId = Convert.ToInt32(listBill[i][0]); billDAOImpl.deleteBill(billref); } Console.WriteLine("step 4"); OrderCredentialsDAO ordercRedDAORef = new OrderCredentialsDAOImpl(); Console.WriteLine("Step5"); ordercRedDAORef.deleteorderCredentials(o); MessageBox.Show("Order cancelled !!"); canecelOrderBtn.Visible = false; try { // Create the Outlook application. Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application(); // Create a new mail item. Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); // Set HTMLBody. //add the body of the email //oMsg.HTMLBody = null; oMsg.HTMLBody = "Order got cancelled!!!!"; //Subject line oMsg.Subject = "Order Details"; // Add a recipient. Microsoft.Office.Interop.Outlook.Recipients oRecips = (Microsoft.Office.Interop.Outlook.Recipients)oMsg.Recipients; // Change the recipient in the next line if necessary. Microsoft.Office.Interop.Outlook.Recipient oRecip = oRecips.Add("*****@*****.**"); oRecip.Resolve(); // Send. oMsg.Send(); // Clean up. oRecip = null; oRecips = null; oMsg = null; oApp = null; }//end of try block catch (Exception ex) { MessageBox.Show(ex.Message); }//end of catch }