示例#1
0
		internal static char GetControlCode(string partialWithoutControlCode)
		{
			var sum = 0;

			sum += new OddCode(partialWithoutControlCode).Total;
			sum += new EvenCode(partialWithoutControlCode).Total;

			var controlCode = new RestCode(sum).ToString();

			return controlCode[0];
		}
示例#2
0
        internal static char GetControlCode(string partialWithoutControlCode)
        {
            var sum = 0;

            sum += new OddCode(partialWithoutControlCode).Total;
            sum += new EvenCode(partialWithoutControlCode).Total;

            var controlCode = new RestCode(sum).ToString();

            return(controlCode[0]);
        }
示例#3
0
        private void btnSaveOrder_Click(object sender, RoutedEventArgs e)
        {
            // checkrestaurants();
            //try
            //{
            string RestCode;

            RestCode = restSearch();
            if (txtdelchrges.Text.Length == 0 || txtdelchrges.Text == null)
            {
                MessageBox.Show("Please Enter the Delivery charges"); txtdelchrges.Focus();
            }
            else
            {
                if (RestCode.Length == 0)
                {
                    MessageBox.Show("Please select restaurant", "Restaurant", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    if (lvOrders.Items.Count > 0)
                    {
                        SqlConnection connection;
                        connection = new SqlConnection(connStr);
                        if (connection.State.ToString() == "open")
                        {
                            connection.Close();
                        }
                        connection.Open();
                        SqlCommand cmd = new SqlCommand("[dbo].[spinsertNewOrderDT]", connection);


                        int     TypeOfOrderId;
                        string  EmpCode;
                        string  CustPhoneNumber;
                        decimal actamt    = decimal.Parse(lblTotalLable.Content.ToString());
                        int     delamount = Convert.ToInt32(txtdelchrges.Text);
                        decimal totalbill = actamt + delamount;

                        //    int hun = Int32.Parse("100");
                        //    Decimal divp = Decimal.Parse("2.5".Replace(".", "."));
                        //// Decimal amt = hun * divp;
                        //decimal cgstcharges = (actamt) / hun * divp;
                        //decimal sgstcharges = (actamt) / hun * divp;
                        decimal  cgstcharges       = Decimal.Parse("0.0".Replace(".", "."));
                        decimal  sgstcharges       = Decimal.Parse("0.0".Replace(".", "."));
                        decimal  totalbillaftergst = (totalbill + (cgstcharges) + (sgstcharges));
                        string   CustRequest       = txtCustInstructions.Text.ToString();
                        string   DeliveryBoyCode   = "";
                        string   channelid         = Cbochannel.SelectedValue.ToString();
                        DateTime tobedeliver       = Convert.ToDateTime(dtDelivery.Value.ToString());
                        if (tobedeliver != System.DateTime.Now)
                        {
                            tobedeliver = tobedeliver.AddMinutes(60);
                        }
                        else
                        {
                            tobedeliver = Convert.ToDateTime(dtDelivery.Value.ToString());
                        }

                        TypeOfOrderId   = Convert.ToInt32(((ComboBoxItem)this.CboTypeOfOrder.SelectedValue).Tag.ToString());
                        EmpCode         = lblEmpCode.Content.ToString();
                        CustPhoneNumber = lblCustPhone.Content.ToString();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@typeoforderid", TypeOfOrderId));
                        cmd.Parameters.Add(new SqlParameter("@employecode", EmpCode));
                        cmd.Parameters.Add(new SqlParameter("@customerphone", CustCode));
                        cmd.Parameters.Add(new SqlParameter("@restcode", RestCode.Trim().ToString()));
                        cmd.Parameters.Add(new SqlParameter("@CustRequest", CustRequest));
                        cmd.Parameters.Add(new SqlParameter("@DeliveryBoyCode", DeliveryBoyCode));
                        cmd.Parameters.Add(new SqlParameter("@channelid", channelid));
                        cmd.Parameters.Add(new SqlParameter("@orderdelivtime", Convert.ToDateTime(DateTime.Now.ToString())));
                        cmd.Parameters.Add(new SqlParameter("@tobedelivered", tobedeliver));
                        cmd.Parameters.Add(new SqlParameter("@deliveryamount", delamount.ToString()));
                        cmd.Parameters.Add(new SqlParameter("@cgstcharges", (cgstcharges)));
                        cmd.Parameters.Add(new SqlParameter("@sgstcharges", (sgstcharges)));
                        SqlParameter outputIdParam = new SqlParameter("@NewId", SqlDbType.Int)
                        {
                            Direction = ParameterDirection.Output
                        };
                        cmd.Parameters.Add(outputIdParam);


                        cmd.ExecuteNonQuery();
                        string idFromString = (outputIdParam.Value.ToString());
                        int    m            = System.DateTime.Now.Month;
                        int    d            = System.DateTime.Now.Day;
                        int    y            = System.DateTime.Now.Year;
                        ///Insesrting order details from the list box
                        if (idFromString.Length == 0)
                        {
                            idFromString = "1";
                        }
                        idFromString = RestCode.ToString().Trim() + d.ToString() + m.ToString() + y.ToString() + "-" + idFromString;
                        for (int i = lvOrders.Items.Count - 1; i >= 0; --i)
                        {
                            var item = lvOrders.Items[i];

                            cmd             = new SqlCommand("insertNewOrdreDetailsBasedOnId", connection);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new SqlParameter("OrderId", idFromString));
                            cmd.Parameters.Add(new SqlParameter("quantity", Convert.ToInt32(((Anakapur.NewOrder.Orders)item).qty)));
                            cmd.Parameters.Add(new SqlParameter("productid", (((Anakapur.NewOrder.Orders)item).code).Trim()));
                            cmd.ExecuteNonQuery();
                        }

                        MessageBox.Show("New Order Saved : " + idFromString.ToString(), "Save Success", MessageBoxButton.OK, MessageBoxImage.Information);
                        txtdelchrges.Text = "";


                        //Uri uri = new Uri("http://inventory.ankapurchicken.com/");

                        //Ping ping = new Ping();
                        //PingReply pingReply = ping.Send(uri.Host);

                        //int Out;
                        //if (pingReply.Status == IPStatus.Success)
                        //{
                        //if (InternetGetConnectedState(out Out, 0) == true)
                        //{
                        try
                        {
                            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Do you want to send SMS?", "SMS", System.Windows.MessageBoxButton.YesNo);
                            if (messageBoxResult == MessageBoxResult.Yes)
                            {
                                SMSCAPI.ServiceSoapClient obj1 = new SMSCAPI.ServiceSoapClient();
                                SMSCAPI.ServiceSoapClient obj2 = new SMSCAPI.ServiceSoapClient();
                                string strPostResponse;
                                string strPostResponse1;
                                //9000754777
                                strPostResponse = obj1.SendTextSMS("ankapurchicken", "ankapur6900", "9000754777", "Order Received!!!        Order id:" + idFromString.ToString() + "                       " + "Grand Total Rs:" + totalbillaftergst.ToString() + "              " + "Name: " + lblCustName.Content.ToString() + "              " + "Customer Phone: " + lblCustPhone.Content.ToString() + "           " + "Items:" + lvOrders.Items.Count.ToString(), "ANKPUR");      //hn
                                //     strPostResponse = obj1.SendTextSMS("ankapurchicken", "ankapur6900", "9494942342", "Order Received!!!        Order id:" + idFromString.ToString() + "                       " + "Grand Total Rs:" + totalbillaftergst.ToString() + "              " + "Name: " + lblCustName.Content.ToString() + "              " + "Customer Phone: " + lblCustPhone.Content.ToString() + "           " + "Items:" + lvOrders.Items.Count.ToString(), "ANKPUR"); //asrao
                                //  strPostResponse = obj1.SendTextSMS("ankapurchicken", "ankapur6900", "7032925185", "Order Received!!!        Order id:" + idFromString.ToString() + "                       " + "Grand Total Rs:" + totalbillaftergst.ToString() + "              " + "Name: " + lblCustName.Content.ToString() + "              " + "Customer Phone: " + lblCustPhone.Content.ToString() + "           " + "Items:" + lvOrders.Items.Count.ToString(), "ANKPUR"); //kp
                                strPostResponse1 = obj2.SendTextSMS("ankapurchicken", "ankapur6900", lblCustPhone.Content.ToString(), "Thank you for ordering with Ankapur Chicken your  Order id:" + idFromString.ToString() + "   " + "Grand Total Rs:" + totalbillaftergst.ToString() + "(incl GST and delivery charges)", "ANKPUR");

                                string delReport;
                                string delReport1;
                                delReport  = obj1.Getbalance("ankapurchicken", "ankapur6900");
                                delReport1 = obj2.Getbalance("ankapurchicken", "ankapur6900");
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Please Check the internet Connection!!! Messages Cannot be sent at the moment", "Internet Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                        //}
                        //else
                        //{
                        //    MessageBox.Show("Please Check the internet Connection!!! Messages Cannot be sent at the moment", "Internet Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        //}
                        //}
                        //else
                        //{ MessageBox.Show("Please Check the internet Connection!!! Messages Cannot be sent at the moment", "Internet Error", MessageBoxButton.OK, MessageBoxImage.Warning); }
                        connection.Close();
                        lblOrderID.Content = idFromString.ToString();
                        lvOrders.Items.Clear();
                        lblCustAddr.Text     = "";
                        lblCustName.Content  = "";
                        lblCustPhone.Content = "";
                        Application.Current.Properties["custPhone"] = "";
                        lblTotalLable.Content = "Total : ";
                        wrpPanel.Visibility   = Visibility.Hidden;
                        wrpPanel.Children.Clear();
                        FillAgentOrders();
                    }
                    else
                    {
                        MessageBox.Show("No items to Save", "Save Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            // }
            //catch (Exception)
            //{
            //    MessageBox.Show("Order is not saved please place the order again");
            //}
        }