예제 #1
0
        /// <summary>
        /// 下线界面中确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btndone_Click(object sender, EventArgs e)
        {
            isExitType     = true;
            Info.exit_date = DateTime.Now;
            //下线更新pos_rounds表(本地)
            if (InsertPos_rounds.InitController().Update_Posrounds(Info.exit_date))
            {
                //创建一个线程用于打印下线小票
                Thread thread = new Thread(new ThreadStart(Run));
                thread.Start();
                //删除提单前的空的销售单
                ChangeInfo changeinfo = new ChangeInfo();
                changeinfo.DelSaletmp00(Info.sale_id);
                ReadIni readIni = new ReadIni();
                readIni.WriteString("RepastErp", "sale_id", "");
                //删除本地临时表中符合要求的数据
                DelLocalDB dellocaldb = new DelLocalDB(this.mainForm);
                dellocaldb.DelSaletmp();

                this.Dispose();
            }
            //else
            //{
            //    MessageBox.Show("下线失败!请在本Pos机上下线。");
            //}
        }
        /// <summary>
        /// 主窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MainForm_Load(object sender, EventArgs e)
        {
            this.Visible = false;
            ReadIni readIni = new ReadIni();

            CreateDB();

            Info.printPort   = operPara1.GetIniConfig("printPort");
            Info.cusShowPort = operPara1.GetIniConfig("cusShowPort");
            Info.showPort    = operPara1.GetIniConfig("showPort");
            Info.ICPort      = operPara1.GetIniConfig("ICPort");

            #region 生成连接字符串
            string localIp = this.operPara1.LocalIp;
            if (localIp == "")
            {
                string strHostName = Dns.GetHostName();                            //得到本机的主机名
                localIp = Dns.GetHostEntry(strHostName).AddressList[0].ToString(); //取得本机IP
            }
            //创建带实例名的连接
            Info.Constr = "server=" + localIp + @"\" + this.operPara1.LocalCase + "," + this.operPara1.LocalPort + ";" + "database=" + this.operPara1.LocalDBName + ";" + "uid=" + this.operPara1.LocalUserName + ";pwd=" + "'" + this.operPara1.LocalPassword + "'";
            #endregion
            try
            {
                Info.insertSingleProd = new InsertSingleProd();
                Info.getProduct       = new GetProduct0();
                login          = new Login();
                login.MainForm = this;
                login.ShowDialog();

                this.functionPanel.LoadBtnInfo(Info.emp_id, "", true);

                if (recoverSucess)
                {
                    //加载商品类别信息
                    this.btnPanelKind.LoadInfo(0, true);
                    this.Visible       = true;
                    this.recoverSucess = false;
                    //若上次处于结账状态,恢复成功时恢复结账前状态
                    UpdateSales.InitUpdateSales().DelSalesSucess();
                    this.orderMenu.LoadInfo();
                    return;
                }

                #region 如果本地数据库中的数据达到一定要求则按条件删除一部分
                DelLocalDB del = new DelLocalDB(this);
                del.DelLocalData();
                #endregion

                //加载商品类别信息
                this.btnPanelKind.LoadInfo(0, true);
                this.Visible = true;
            }
            catch { }
        }