예제 #1
0
        private void RefreshDgv()
        {
            dataGridView1.Rows.Clear();
            SQLiteDataReader msdr = SqlModlus.getUserAllMsg(dateTimePicker1.Value.Date.ToString(), dateTimePicker2.Value.AddDays(1).Date.ToString());
            int    i        = 0;
            double tmpPrice = 0;

            while (msdr.Read())
            {
                string pay = "";
                switch (msdr["PayType"].ToString())
                {
                case "0":
                    pay = "支付宝";
                    break;

                case "1":
                    pay = "微信";
                    break;

                case "2":
                    pay = "QQ";
                    break;

                case "3":
                    pay = "VIP";
                    break;

                case "4":
                    pay = "未付款";
                    break;
                }
                double p     = 0;
                string price = msdr["Price"] == DBNull.Value ? "0" : msdr["Price"].ToString();
                if (!double.TryParse(msdr["Price"].ToString(), out p))
                {
                    p = 0;
                }
                dataGridView1.Rows.Add();
                dataGridView1.Rows[i].Cells["用户ID"].Value = msdr["UserID"];
                dataGridView1.Rows[i].Cells["用户名"].Value  = msdr["UserName"];
                dataGridView1.Rows[i].Cells["录单时间"].Value = msdr["LoadTime"];
                dataGridView1.Rows[i].Cells["出货时间"].Value = msdr["FinishTime"];
                dataGridView1.Rows[i].Cells["配送时间"].Value = msdr["Time"];
                dataGridView1.Rows[i].Cells["消费金额"].Value = p;
                dataGridView1.Rows[i].Cells["支付方式"].Value = pay;
                dataGridView1.Rows[i].Cells["小票预览"].Value = "小票预览";
                tmpPrice += p;
                i++;
            }
            msdr.Close();
            tmpPrice   = tmpPrice + 0.35;
            当日总金额.Text = Math.Round(tmpPrice, 1, MidpointRounding.AwayFromZero).ToString() + " 元";
        }
예제 #2
0
        public bool InsertOrUpdateUser(UserDB user)
        {
            bool b = SqlModlus.ChecUserExist(user);

            if (b)
            {
                return(SqlModlus.UpdateUserMsg(user));
            }
            else
            {
                return(SqlModlus.InsertUserMsg(user));
            }
        }
예제 #3
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows == null && dataGridView1.SelectedRows.Count == 0)
     {
         MessageBox.Show("请选择要删除的行!");
         return;
     }
     SqlModlus.DeleteUserMsg(new UserDB()
     {
         userName = dataGridView1.SelectedRows[0].Cells["用户名"].Value.ToString()
     });
     dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
 }
예제 #4
0
        private void callBack(IAsyncResult ar)
        {
            bool     b      = func.EndInvoke(ar);
            GroupMsg tmpmsg = ar.AsyncState as GroupMsg;

            if (b)
            {
                UserDB udb = new UserDB()
                {
                    userName = tmpmsg.GroupName, lastAddr = tmpmsg.Area, lastTime = DateTime.Parse(tmpmsg.LoadTime), phone = tmpmsg.Phone
                };
                if (tmpmsg.FileMsgList.Count(t => int.Parse(t.state) < 3) == 0)
                {
                    OutUser(tmpmsg, udb);
                    //ExcelHelper.AddMs(tmpmsg);
                }
                SqlModlus.SaveGroupMsg(tmpmsg);
                if (str.Length > 0)
                {
                    MessageBox.Show("打印异常:" + str);
                    str = "";
                }
                foreach (var v in tmpmsg.FileMsgList)
                {
                    if (usingPrinter.ContainsKey(v.Printer))
                    {
                        usingPrinter[v.Printer] = false;
                    }
                }
                tmpmsg.isPrint = false;
            }
            else
            {
                if (tmpmsg.isAbort)
                {
                    tmpmsg.FileMsgList.ForEach(t => t.state = "0");
                }
                foreach (var v in tmpmsg.FileMsgList)
                {
                    if (usingPrinter.ContainsKey(v.Printer))
                    {
                        usingPrinter[v.Printer] = false;
                    }
                }
            }
            tmpmsg.isPrint     = false;
            tmpmsg.isAbort     = false;
            tmpmsg.isCanceling = false;
        }
예제 #5
0
 private void frm_Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!unInit)
     {
         if (main.groupList.FindIndex(t => t.isPrint == true) != -1)
         {
             MessageBox.Show("请打印文件完成后再退出!");
             e.Cancel = true;
         }
         if (this.Text.IndexOf(preString) != -1)
         {
             this.Text.Replace(preString, "-正在关闭...");
         }
         else
         {
             this.Text += "-正在关闭...";
         }
         foreach (var v in main.groupList)
         {
             if (!v.isRemove)
             {
                 SqlModlus.SaveGroupMsg(v);
             }
         }
         try
         {
             bExit               = true;
             WordToPdf.RunFlag   = false;
             ExcelHelper.RunFlag = false;
             WordToPdf.Stop();
             ExcelHelper.Stop();
             foreach (var v in FileHelper.lockFileList)
             {
                 v.fs.Close();
                 File.Delete(v.FullName);
             }
             LogOperate.Add("软件关闭!");
             LogOperate.Stop();
         }
         catch { }
     }
 }
예제 #6
0
 public void OutUser(GroupMsg tmpmsg, UserDB udb)
 {
     tmpmsg.FinishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     tmpmsg.state      = "3";
     if (tmpmsg.FileDirectory == null)
     {
         tmpmsg.FileDirectory = frm_Main.CurrentPath;
     }
     SqlModlus.InsertUserMsg(tmpmsg);
     main.InsertOrUpdateUser(udb);
     if (null != tmpmsg.FileMsgList)
     {
         foreach (FileMsg fmsg in tmpmsg.FileMsgList)
         {
             SqlModlus.InsertFileMsg(fmsg, tmpmsg.GroupName);
             fmsg.state = "3";
         }
     }
     tmpmsg.isShow = true;
 }
예제 #7
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == -1 || e.RowIndex == -1)
     {
         return;
     }
     if (dataGridView1.Columns[e.ColumnIndex].Name == "小票预览")
     {
         GroupMsg groupMsg = SqlModlus.GetGroupMsg(dataGridView1.Rows[e.RowIndex].Cells["用户ID"].Value.ToString(), dataGridView1.Rows[e.RowIndex].Cells["用户名"].Value.ToString());
         if (groupMsg == null)
         {
             MessageBox.Show("获取小票失败!");
             return;
         }
         int   h   = 0;
         Image img = ImageHelper.CreateImage(groupMsg, out h);
         pictureBox1.Height = h;
         pictureBox1.Image  = img;
     }
 }
예제 #8
0
        private void RefreshDgv()
        {
            dataGridView1.Rows.Clear();
            SQLiteDataReader msdr = SqlModlus.GetAllUserMsg();

            while (msdr.Read())
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[rowCount].Cells["用户名"].Value   = msdr["UserName"];
                dataGridView1.Rows[rowCount].Cells["上次地点"].Value  = msdr["LastAddr"];
                dataGridView1.Rows[rowCount].Cells["电话"].Value    = msdr["Phone"];
                dataGridView1.Rows[rowCount].Cells["消费总金额"].Value = SqlModlus.GetPriceSum(new UserDB()
                {
                    userName = msdr["UserName"].ToString()
                });
                dataGridView1.Rows[rowCount].Cells["上次下单时间"].Value = msdr["LastTime"];
                dataGridView1.Rows[rowCount].Cells["用户属性备注"].Value = msdr["Note"];
                rowCount++;
            }
            msdr.Close();
        }
예제 #9
0
        public static void GetUserMsg(string root)
        {
            string destPath = System.Windows.Forms.Application.StartupPath + @"\tmpCaeaload";

            if (!Directory.Exists(destPath))
            {
                Directory.CreateDirectory(destPath);
            }
            int             i           = 0;
            DirectoryInfo   tmpRootInfo = new DirectoryInfo(root);
            List <GroupMsg> tmpList     = new List <GroupMsg>();

            DirectoryInfo[] tmpInfoArray = tmpRootInfo.GetDirectories();
            foreach (var tmpInfo in tmpInfoArray)
            {
                if (frm_Main.bExit)
                {
                    break;
                }
                if (FileHelper.GetFileCount(tmpInfo) == 0)
                {
                    //tmpInfo.Delete();
                    //MessageBox.Show("文件夹:" + tmpInfo.Name + " 异常!");
                    LogOperate.Add("文件夹:" + tmpInfo.Name + "为空");
                    //tmpInfoArray = tmpRootInfo.GetDirectories();
                    continue;
                }
                List <FileMsg> tmpFileMsg = new List <FileMsg>();
                string         tmps       = destPath + "\\" + tmpInfo.Name + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "(_caeaload)";
                string         newName    = tmps.Replace(destPath + "\\", "");
                if ((tmpFileMsg = GetAllFile(tmpInfo, tmpInfo.Name, newName, tmps, tmpInfo.FullName)) != null && tmpFileMsg.Count != 0)
                {
                    try
                    {
                        newName = tmpInfo.Name;
                        LogOperate.Add("开始移动订单:" + tmpInfo.Name);
                        tmpInfo.MoveTo(tmps);
                    }
                    catch (Exception ex)
                    {
                        LogOperate.Add("移动订单失败:" + tmpInfo.Name + "," + ex.Message);
                        //MessageBox.Show("移动订单失败:" + tmpInfo.Name + "," + ex.Message);
                        Thread.Sleep(100);
                        tmpInfoArray = tmpRootInfo.GetDirectories();
                        continue;
                    }

                    GroupMsg groupmsg = new GroupMsg()
                    {
                        UserID        = tmpInfo.Name,
                        CreateTime    = tmpInfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        FileMsgList   = tmpFileMsg,
                        LoadTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        FileDirectory = frm_Main.CurrentPath,
                        state         = "0",
                        GroupName     = newName,
                        Count         = "1",
                        PageCount     = tmpFileMsg.Sum(t => t.PageCount == "----" ? 0 : int.Parse(t.PageCount)).ToString(),
                        //initPageCount = tmpFileMsg.Sum(t => t.PageCount == -1 ? 0 : t.PageCount),
                        VerForm    = "正反",
                        PrintColor = "黑白",
                        PaperType  = GetPaperType.defaultBWPaper,
                        Printer    = GetPrinterType.defaultBWPrinter,
                        PayType    = "4",
                        SetTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        FullName   = tmpInfo.FullName.Trim('\\'),
                        isInit     = true
                    };
                    groupmsg.FileName      = groupmsg.GetDisplayFileName();
                    groupmsg.InitPageCount = groupmsg.PageCount;
                    groupmsg.InitPrice     = "-2";
                    tmpList.Add(groupmsg);
                    Thread.Sleep(10);
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
            #region
            //while (tmpInfoArray.Count() > 0)
            //{
            //    if (frm_Main.bExit)
            //        break;
            //    DirectoryInfo tmpInfo = tmpInfoArray[0];
            //    if (FileHelper.GetFileCount(tmpInfo) == 0)
            //    {
            //        //tmpInfo.Delete();
            //        MessageBox.Show("文件夹:" + tmpInfo.Name + " 异常!");
            //        tmpInfoArray = tmpRootInfo.GetDirectories();
            //        continue ;
            //    }
            //    List<FileMsg> tmpFileMsg = new List<FileMsg>();
            //    string tmps = destPath + "\\" + tmpInfo.Name + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "(_caeaload)";
            //    string newName = tmps.Replace(destPath + "\\","");
            //    if ((tmpFileMsg = GetAllFile(tmpInfo, tmpInfo.Name, newName, tmps, tmpInfo.FullName)) != null && tmpFileMsg.Count != 0)
            //    {
            //        try
            //        {
            //            newName = tmpInfo.Name;
            //            LogOperate.Add("开始移动订单:" + tmpInfo.Name);
            //            tmpInfo.MoveTo(tmps);

            //        }
            //        catch (Exception ex)
            //        {
            //            LogOperate.Add("移动订单失败:" + tmpInfo.Name + "," + ex.Message);
            //            MessageBox.Show("移动订单失败:" + tmpInfo.Name + "," + ex.Message);
            //            Thread.Sleep(100);
            //            tmpInfoArray = tmpRootInfo.GetDirectories();
            //            continue;
            //        }

            //        GroupMsg groupmsg = new GroupMsg()
            //        {
            //            UserID = tmpInfo.Name,
            //            CreateTime = tmpInfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
            //            FileMsgList = tmpFileMsg,
            //            LoadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
            //            FileDirectory = frm_Main.CurrentPath,
            //            state = "0",
            //            GroupName = newName,
            //            Count = "1",
            //            PageCount = tmpFileMsg.Sum(t => t.PageCount == "----" ? 0: int.Parse( t.PageCount)).ToString(),
            //            //initPageCount = tmpFileMsg.Sum(t => t.PageCount == -1 ? 0 : t.PageCount),
            //            VerForm = "正反",
            //            PrintColor = "黑白",
            //            PaperType = GetPaperType.defaultBWPaper,
            //            Printer = GetPrinterType.defaultBWPrinter,
            //            PayType = "4",
            //            SetTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
            //            FullName = tmpInfo.FullName.Trim('\\'),
            //            isInit = true
            //        };
            //        groupmsg.FileName = groupmsg.GetDisplayFileName();
            //        groupmsg.InitPageCount = groupmsg.PageCount;
            //        groupmsg.InitPrice = "-2";
            //        tmpList.Add(groupmsg);
            //        Thread.Sleep(10);
            //    }
            //    else
            //        Thread.Sleep(100);
            //    tmpInfoArray = tmpRootInfo.GetDirectories();
            //}
            #endregion
            foreach (var v in tmpList)
            {
                UserDB userDB = SqlModlus.selectUserMsg(v.GroupName);
                v.Printer   = v.FileMsgList.Count() == v.FileMsgList.Count(t => t.isNormalFile) ? "----" : GetPrinterType.defaultBWPrinter;
                v.PaperType = GetPaperType.defaultBWPaper;
                v.Area      = FileHelper.addrList.Contains(userDB.lastAddr) ? userDB.lastAddr : null;
                v.Phone     = userDB.phone;
                foreach (var subv in v.FileMsgList)
                {
                    subv.Printer   = subv.isNormalFile ? "----" : GetPrinterType.defaultBWPrinter;
                    subv.PaperType = GetPaperType.defaultBWPaper;
                    subv.Price     = subv.GetPrice();
                    subv.InitPrice = "-2";
                }
                v.Price = v.GetPrice();
                v.GetDisplayVerForm();
            }

            foreach (var v in tmpList)
            {
                if (v.FileMsgList.Count == 0)
                {
                    MessageBox.Show("订单有效文件为空!");
                    continue;
                }
                if (!SqlModlus.InsertTmpUserMsg(v))
                {
                    MessageBox.Show("订单保存异常!");
                }
                Thread.Sleep(1);
                foreach (var v1 in v.FileMsgList)
                {
                    if (!SqlModlus.InsertTmpFileMsg(v1))
                    {
                        MessageBox.Show("文件保存异常!");
                    }
                    Thread.Sleep(1);
                }
            }
            if (main.groupList == null)
            {
                main.groupList = new List <GroupMsg>();
            }
            foreach (var v in main.groupList)
            {
                if (v.isRemove)
                {
                    continue;
                }
                if (v.isManual)
                {
                    v.isInit = true;
                    continue;
                }
            }
            main.groupList.AddRange(tmpList);
            main.groupList.ForEach(t => t.isPrint = false);
            //main.groupList.RemoveAll(t => t.isRemove == true);
        }
예제 #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //File.AppendAllLines(@"E:\代码\C#\Winform\私单\打印管理20190916\20190820\打印管理\打印管理\bin\Debug\log\logtext 20190926 171728.txt",new string[] { "123456"});

            bool b = SQLiteHelper.SQLiteInit(string.Format(@"Data Source={0}\PrintDB.db", Application.StartupPath), "jtmes");

            if (b)
            {
                KeyPreview = true;
                try
                {
                    foreach (var v in toolStrip1.Items)
                    {
                        if (v is ToolStripButton)
                        {
                            ToolStripButton Tbtn = v as ToolStripButton;
                            if (Convert.ToString(Tbtn.Tag) == "1")
                            {
                                Tbtn.Paint     += toolStrip1_Paint;
                                Tbtn.MouseMove += toolStrip1_MouseMove;
                            }
                        }
                    }
                    logFlag = Convert.ToBoolean(ConfigClass.GetConfigString("sys", "log", "true"));
                    LogOperate.Init();
                    LogOperate.Start();
                    LogOperate.Add("软件运行");
                    CurrentPath = ConfigClass.GetConfigString("File", "path", "");
                    if (!Directory.Exists(CurrentPath))
                    {
                        FolderBrowserDialog f = new FolderBrowserDialog();
                        if (f.ShowDialog() == DialogResult.OK)
                        {
                            CurrentPath = f.SelectedPath;
                            ConfigClass.SetConfigString("File", "path", CurrentPath);
                        }
                        else
                        {
                            unInit = true;
                            Application.Exit();
                        }
                    }
                    string strFastPrint = ConfigClass.GetConfigString("Printer", "speed", "false");
                    CK_fastPrint.Checked = strFastPrint.ToUpper() == "TRUE" ? true : false;
                    nFastPrint           = CK_fastPrint.Checked;
                    bool bConvert = Convert.ToBoolean(ConfigClass.GetConfigString("sys", "Convert", "false"));
                    if (bConvert)
                    {
                        timer2.Interval = 1000;
                        timer2.Enabled  = true;
                    }
                    else
                    {
                        fileWatcher.Path = CurrentPath;
                        fileWatcher.EnableRaisingEvents = true;
                    }
                    sysConfigData.printerName = ConfigClass.GetConfigString("sys", "小票打印机", "");
                    sysConfigData.ShopName    = ConfigClass.GetConfigString("sys", "店铺名称", "");
                    sysConfigData.BarcodePath = ConfigClass.GetConfigString("sys", "二维码路径", "");
                    sound = new System.Media.SoundPlayer("Audio.wav");
                    sound.Load();
                    //main.groupList = ConfigClass.LoadCookie<GroupMsg>("cookie.dat");
                    main.groupList = SqlModlus.selectTmpUserMsg();
                    if (main.groupList == null)
                    {
                        main.groupList = new List <GroupMsg>();
                    }
                    foreach (var v in main.groupList)
                    {
                        if (!v.isManual)
                        {
                            List <FileMsg> fmsg = SqlModlus.selectTmpFileMsg(v.UserID);
                            v.FileMsgList = fmsg;
                        }
                    }
                    main.groupList.ForEach(t => t.isPrint = false);
                    main.groupList.RemoveAll(t => t.isRemove == true);
                    txt_Date.Text = DateTime.Now.Date.ToLongDateString();
                    CurrentDate   = txt_Date.Text;

                    FileHelper.timelist = GetPeopleMsg.GetTimeList();
                    FileHelper.addrList = GetPeopleMsg.GetAddrList();
                    FileHelper.rowMsg   = GetDefaultAddMsg.getMsg();
                    GetPaperType.UpdatePaperList();
                    GetPrinterType.UpdatePrinterList();
                    GetPaperPrice.getPrice();

                    GetUserMsg(CurrentPath);
                    WordToPdf.Start();
                    DealControl(new int[] { 0, 0, 0 });
                    CheckForIllegalCrossThreadCalls = false;
                    treeView1.ExpandAll();
                    treeView1.MouseDoubleClick += new MouseEventHandler(treeView1_DoubleClick);
                    txt_path.Text = CurrentPath;
                    //FileHelper.act.BeginInvoke(frm_Main.CurrentPath, callback, null);
                    frm_MainMenu = New_Form(frm_MainMenu);
                    tooldoWork   = frm_MainMenu.doWork;
                    if (frm_MainMenu != null)
                    {
                        frm_MainMenu.setdgvPos(panel_Parent.Width, panel_Parent.Height);
                    }
                    ExcelHelper.Start();
                    frm_MainMenu.refresh("");
                    toolStrip2.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStrip2_ItemClicked);
                    unInit = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("数据库连接异常!");
            }
        }