コード例 #1
0
ファイル: PlaceOrderUsrCtrl.cs プロジェクト: krathi123/Trial
        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 + " &emsp;" + " &emsp;" + " &emsp;";
                    str     += billRef.quantity + "&emsp;" + "&emsp;" + "&emsp;" + "&emsp;";
                    str     += billRef.price + " &emsp;" + "&emsp;" + "&emsp;" + "&emsp;";
                    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);
        }
コード例 #2
0
ファイル: PlaceOrderUsrCtrl.cs プロジェクト: krathi123/Trial
        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
        }