Beispiel #1
0
        private void btn_pgop_Click(object sender, EventArgs e)
        {
            Print             print = new Print();
            List <CheckBoxEx> lcb   = new List <CheckBoxEx>();
            List <CheckBoxEx> tcb   = new List <CheckBoxEx>();

            for (int i = 0; i < time.Length; i++)
            {
                CheckBoxEx cb = time[i];
                if (cb.Checked == true)
                {
                    lcb.Add(cb);
                }
            }
            for (int i = 0; i < typelist.Length; i++)
            {
                CheckBoxEx cb = typelist[i];
                if (cb.Checked == true)
                {
                    tcb.Add(cb);
                }
            }
            if (lcb.Count == 1)
            {
                String cmdText = "";
                if (lcb.Count > 0)
                {
                    cmdText  = "select f.shortName,o.oTakeTime ,COUNT(*) AS COUNT FROM orders O, orderFood OF, food F WHERE O.orderDate=OF.orderDate AND O.orderId=OF.orderId AND OF.foodId=F.foodId  and o.status = 'processing'";
                    cmdText += "AND O.oTakeTime in(";
                    for (int i = 0; i < lcb.Count; i++)
                    {
                        if (i != 0)
                        {
                            cmdText += ",";
                        }
                        cmdText += "'" + lcb[i].Text + ":00'";
                    }
                    cmdText += ")";
                }
                if (tcb.Count > 0)
                {
                    cmdText += "AND F.fTypeId IN (";
                    for (int i = 0; i < tcb.Count; i++)
                    {
                        if (i != 0)
                        {
                            cmdText += ",";
                        }
                        cmdText += "'" + tcb[i].Tag + "'";
                    }
                    cmdText += ")";
                }
                cmdText += "GROUP BY f.foodId";
                DataTable dt = db.printGrp(cmdText);
                String    s  = "Asia Pacific";

                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    s += "\r" + dt.Rows[j]["shortname"] + "-Qty:" + dt.Rows[j]["count"];
                }
                s += "\rTake Time:" + dt.Rows[0]["otaketime"];
                String[] context = s.Split('\r');
                if (!Directory.Exists(@"C:\\My Documents\\" + todayString + "\\"))
                {
                    DirectoryInfo di = Directory.CreateDirectory(@"C:\\My Documents\\" + todayString + "\\");
                }
                String path = @"C:\\My Documents\\" + todayString + "\\O99999999_99-99-99_(1@1).txt";
                System.IO.File.WriteAllLines(path, context);
                print.print("O99999999_99-99-99_(1@1).txt");
            }
            else
            {
                MessageBox.Show("Please choose one time only.");
            }
        }
Beispiel #2
0
        private void PrintMessage_click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Do you want to print these time group order?", "Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                Print             print    = new Print();
                String            nowTime  = DateTime.Now.ToString("HH-mm-ss");
                String            nowTime2 = nowTime.Substring(0, 2) + ":" + nowTime.Substring(3, 2) + ":" + nowTime.Substring(6, 2);
                List <CheckBoxEx> lcb      = new List <CheckBoxEx>();
                List <CheckBoxEx> tcb      = new List <CheckBoxEx>();
                int printcount             = 0;
                for (int i = 0; i < time.Length; i++)
                {
                    CheckBoxEx cb = time[i];
                    if (cb.Checked == true)
                    {
                        lcb.Add(cb);
                    }
                }
                for (int i = 0; i < typelist.Length; i++)
                {
                    CheckBoxEx cb = typelist[i];
                    if (cb.Checked == true)
                    {
                        tcb.Add(cb);
                    }
                }
                if (lcb.Count > 0)
                {
                    String cmdText = "";
                    if (lcb.Count > 0)
                    {
                        cmdText  = "select * FROM orders O, orderFood OF, food F WHERE O.orderDate=OF.orderDate AND O.orderId=OF.orderId AND OF.foodId=F.foodId  and o.status = 'processing'";
                        cmdText += "AND O.oTakeTime in(";
                        for (int i = 0; i < lcb.Count; i++)
                        {
                            if (i != 0)
                            {
                                cmdText += ",";
                            }
                            cmdText += "'" + lcb[i].Text + ":00'";
                        }
                        cmdText += ")";
                    }
                    if (tcb.Count > 0)
                    {
                        cmdText += "AND F.fTypeId IN (";
                        for (int i = 0; i < tcb.Count; i++)
                        {
                            if (i != 0)
                            {
                                cmdText += ",";
                            }
                            cmdText += "'" + tcb[i].Tag + "'";
                        }
                        cmdText += ")";
                    }
                    cmdText += "GROUP BY o.orderid";
                    DataTable dt = db.printGrp(cmdText);
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        printcount++;
                        String counter = "(" + printcount + "/" + dt.Rows.Count + ")";
                        String s       = "Asia Pacific";
                        s += "\r" + dt.Rows[j]["orderid"];
                        DataTable orderDt = db.getDb2(dt.Rows[j]["orderid"].ToString());
                        for (int k = 0; k < orderDt.Rows.Count; k++)
                        {
                            s += "\r" + orderDt.Rows[k]["shortname"];
                        }
                        s += "\rTake Time:" + dt.Rows[j]["otaketime"]; //get order string end
                        s += "\r" + nowTime2;
                        s += "\r" + counter;

                        String[] context = s.Split('\r');
                        if (!Directory.Exists(@"C:\\My Documents\\" + todayString + "\\"))
                        {
                            DirectoryInfo di = Directory.CreateDirectory(@"C:\\My Documents\\" + todayString + "\\");
                        }
                        String path = @"C:\\My Documents\\" + todayString + "\\" + context[1] + "_" + nowTime + "_(" + printcount + "@" + dt.Rows.Count + ").txt";
                        System.IO.File.WriteAllLines(path, context);
                        String filename = (context[1] + "_" + nowTime + "_(" + printcount + "@" + dt.Rows.Count + ").txt");
                        print.print(filename);
                        db.update(context[1], nowTime2);
                    }
                }
                if (lcb.Count == 0)
                {
                    MessageBox.Show("Plesae choose time first!");
                }
            }
            else
            {
                MessageBox.Show("Printing is Canelled");
            }
        }