Exemple #1
0
        private void label14_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txt_branch_no.Text.Trim().Length == 0)
                {
                    new MsgForm("机构编码不能为空").ShowDialog();
                    return;
                }
                IBLL.ISysBLL bll = new BLL.SysBLL();
                var          lst = new List <Model.bt_par_setting>();
                lst.Add(new Model.bt_par_setting {
                    par_id = "branch_no", par_val = txt_branch_no.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "jh", par_val = txt_jh.Text
                });
                bll.UpdateParSetting(lst);
                Program.branch_no = txt_branch_no.Text;
                Program.jh        = txt_jh.Text;

                var frm = new MsgForm("初始化设置成功");
                frm.ShowDialog();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                new MsgForm(ex.GetMessage()).ShowDialog();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Exemple #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //
            path = Application.StartupPath;
            //注册表
            Registry();

            /*
             * IBLL.IPayBLL pbll = new BLL.PayBLL();
             * string sheet_no = "";
             * Program.jh = "001";
             * pbll.MicroPay("81231000525321", "W", 0.01M, "135495986333499595", out sheet_no);
             */

            //处理未捕获的异常
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            //处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            try
            {
                //更新软件
                if (!Debugger.IsAttached)
                {
                    SoftUpdate.Update();
                }


                //验证程序
                //if (SoftUpdate.VerifySoft() != 1)
                //{
                //    MessageBox.Show("没有找到加密狗!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    System.Environment.Exit(0);
                //}

                //创建数据库文件
                try
                {
                    if (!System.IO.Directory.Exists(path + "\\logs"))
                    {
                        System.IO.Directory.CreateDirectory(path + "\\logs");
                    }
                    if (!System.IO.Directory.Exists(path + "\\setting"))
                    {
                        System.IO.Directory.CreateDirectory(path + "\\setting");
                    }
                    if (System.IO.Directory.Exists(path + "\\data") == false)
                    {
                        System.IO.Directory.CreateDirectory(path + "\\data");
                    }
                    string db_file = Application.StartupPath + "\\data\\data";
                    if (System.IO.File.Exists(db_file) == false)
                    {
                        SQLiteByHandClose.CreateFile(db_file);
                    }
                    conn = "Data Source=" + db_file + ";Version=3;Pooling=False;Max Pool Size=100;";
                    var db = new DB.SQLiteByHandClose(conn);
                    db.Open();
                    Program.db = db;
                    Program.db.ExecuteScalar("PRAGMA synchronous = OFF;", null);
                    create_table.bt_sysn_info.Upgrade(db);
                    create_table.bt_par_setting.Upgrade(db);
                    create_table.bi_t_item_cls.Upgrade(db);
                    create_table.bi_t_item_info.Upgrade(db);
                    create_table.bi_t_supcust_info.Upgrade(db);
                    create_table.ic_t_branch_stock.Upgrade(db);
                    create_table.ot_pay_flow.Upgrade(db);
                    create_table.ic_t_inout_store_detail.Upgrade(db);
                    create_table.ic_t_inout_store_master.Upgrade(db);
                    create_table.sa_t_operator_i.Upgrade(db);
                    create_table.sm_t_salesheet.Upgrade(db);
                    create_table.sm_t_salesheet_detail.Upgrade(db);
                    create_table.t_order_detail.Upgrade(db);
                    create_table.bi_t_branch_info.Upgrade(db);
                    create_table.sys_t_sheet_no.Upgrade(db);
                    create_table.bi_t_cust_price.Upgrade(db);
                    create_table.bi_t_sup_item.Upgrade(db);
                    create_table.sys_t_system.Upgrade(db);
                    create_table.t_print_log.Upgrade(db);
                    create_table.t_clear_db_log.Upgrade(db);
                    create_table.t_click_log.Upgrade(db);
                }
                catch (Exception ex)
                {
                    Log.writeLog("创建数据库失败", ex.ToString(), null);
                    var frm = new Forms.MsgForm(ex.GetMessage());
                    frm.ShowDialog();
                    return;
                    //throw ex;
                }

                //检测打印机参数设置
                if (Appsetting.is_print == "1" && Appsetting.print_name == "")
                {
                    var frm = new Forms.MsgForm("请先设置打印机");
                    frm.ShowDialog();
                    return;
                }

                //删除过期数据
                IBLL.ISysBLL bll = new BLL.SysBLL();
                if (1 == 1)
                {
                    try
                    {
                        bll.DeleteOldData();
                    }
                    catch (Exception ex)
                    {
                        Log.writeLog("删除过期数据失败", ex.ToString(), null);
                        var frm = new Forms.MsgForm(ex.GetMessage());
                        frm.ShowDialog();
                    }
                }

                //
                ReadWeight = new BLL.ReadWeight_Common();
                is_run     = true;
                try
                {
                    Thread t = new Thread(() => {
                        while (true)
                        {
                            try
                            {
                                IBLL.IClientBLL bll2 = new BLL.ClientBLL();
                                //判断网络连接状态
                                is_connect = bll2.CheckConnect();

                                for (var i = 0; i < 30; i++)
                                {
                                    Thread.Sleep(1000);
                                    if (!is_run)
                                    {
                                        System.Environment.Exit(0);
                                        break;
                                    }
                                }

                                //30秒自动上传销售和采购数据
                                if (is_connect && is_login)
                                {
                                    int errId     = 0;
                                    string errMsg = "";
                                    bll2.UpLoadSale(out errId, out errMsg);

                                    errId  = 0;
                                    errMsg = "";
                                    bll2.UpLoadInOut(out errId, out errMsg);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("网络异常[2001]:" + ex.GetMessage());
                            }
                        }
                    });
                    t.Start();
                }
                catch (Exception ex)
                {
                    Log.writeLog("连接服务器异常", ex.ToString(), null);
                    var frm = new Forms.MsgForm(ex.GetMessage());
                    frm.ShowDialog();
                }
                //判断基础档案更新
                try
                {
                    Thread t = new Thread(() =>
                    {
                        while (true)
                        {
                            try
                            {
                                IBLL.IClientBLL bll2 = new BLL.ClientBLL();
                                int errId            = 0;
                                string errMsg        = "";
                                item_count           = bll2.GetItemCount(out errId, out errMsg);
                                sup_count            = bll2.GetSupCusCount(out errId, out errMsg);
                                cus_price_count      = bll2.GetCusPriceCount("", "", out errId, out errMsg);
                                sup_price_count      = bll2.GetSupPriceCount("", "", out errId, out errMsg);


                                if (is_connect && is_login)
                                {
                                    errId  = 0;
                                    errMsg = "";
                                    bll2.DownLoadItemCls(out errId, out errMsg);

                                    errId  = 0;
                                    errMsg = "";
                                    bll2.DownLoadItem(out errId, out errMsg);

                                    errId  = 0;
                                    errMsg = "";
                                    bll2.DownLoadSupCus(out errId, out errMsg);

                                    errId  = 0;
                                    errMsg = "";
                                    bll2.DownLoadCusPrice("", "", out errId, out errMsg);

                                    errId  = 0;
                                    errMsg = "";
                                    bll2.DownLoadSupPrice("", "", out errId, out errMsg);
                                }

                                Thread.Sleep(5 * 60 * 1000);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("网络异常[2002]:" + ex.GetMessage());
                            }
                        }
                    });
                    t.Start();
                }
                catch (Exception ex)
                {
                    Log.writeLog("判断基础档案更新异常", ex.ToString(), null);
                }
                //
                try
                {
                    var lst = bll.GetParSettingList();
                    foreach (Model.bt_par_setting item in lst)
                    {
                        if (item.par_id == "mo_ling")
                        {
                            mo_ling = item.par_val;
                        }
                        else if (item.par_id == "weight_model")
                        {
                            weight_model = item.par_val;
                        }
                        else if (item.par_id == "branch_no")
                        {
                            branch_no = item.par_val;
                        }
                        else if (item.par_id == "jh")
                        {
                            jh = item.par_val;
                        }
                        else if (item.par_id == "input_cus_model")
                        {
                            input_cus_model = item.par_val;
                        }
                        else if (item.par_id == "print_count")
                        {
                            print_count = Conv.ToInt(item.par_val);
                        }
                        else if (item.par_id == "can_input_qty")
                        {
                            can_input_qty = item.par_val;
                        }
                        else if (item.par_id == "is_continue_weight")
                        {
                            is_continue_weight = item.par_val;
                        }
                    }
                    if (branch_no.Length == 0)
                    {
                        if (new Forms.frmInitSetting().ShowDialog() == DialogResult.OK)
                        {
                            if (new Forms.WaitForm("正在加载数据,请稍候", "1").ShowWait())
                            {
                                if (new Forms.NewLoginForm().Login())
                                {
                                    Application.Run(new Forms.frmMenu());
                                }
                            }
                        }
                        else
                        {
                            System.Environment.Exit(0);
                        }
                    }
                    else
                    {
                        if (new Forms.WaitForm("正在加载数据,请稍候", "1").ShowWait())
                        {
                            if (new Forms.NewLoginForm().Login())
                            {
                                Application.Run(new Forms.frmMenu());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.writeLog("系统异常", ex.ToString(), null);
                    var frm = new Forms.MsgForm(ex.GetMessage());
                    frm.ShowDialog();
                }
            }
            catch (Exception e)
            {
                string str         = "";
                string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";

                if (e != null)
                {
                    str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                                        e.GetType().Name, e.Message, e.StackTrace);
                }
                else
                {
                    str = string.Format("应用程序线程错误:{0}", e);
                }
                Log.writeLog("Main", str);

                MessageBox.Show("系统错误!Message:" + e.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void label14_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (txt_branch_no.Text.Trim().Length == 0)
                {
                    new MsgForm("机构编码不能为空").ShowDialog();
                    return;
                }
                string mo_ling         = "0";
                string weight_model    = "1";
                string input_cus_model = "1";
                if (radioButton2.Checked)
                {
                    mo_ling = "1";
                }
                else if (radioButton3.Checked)
                {
                    mo_ling = "2";
                }
                else if (radioButton4.Checked)
                {
                    mo_ling = "3";
                }

                if (radioButton6.Checked)
                {
                    weight_model = "2";
                }

                if (radioButton8.Checked)
                {
                    input_cus_model = "2";
                }

                var can_input_qty = "1";
                if (!chk_input_qty.Checked)
                {
                    can_input_qty = "0";
                }

                var is_continue_weight = "0";
                if (chk_continue_weight.Checked)
                {
                    is_continue_weight = "1";
                }

                IBLL.ISysBLL bll = new BLL.SysBLL();
                var          lst = new List <Model.bt_par_setting>();
                lst.Add(new Model.bt_par_setting {
                    par_id = "mo_ling", par_val = mo_ling
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "weight_model", par_val = weight_model
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "branch_no", par_val = txt_branch_no.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "jh", par_val = txt_jh.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "input_cus_model", par_val = input_cus_model
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "print_count", par_val = txt_print_count.Text
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "can_input_qty", par_val = can_input_qty
                });
                lst.Add(new Model.bt_par_setting {
                    par_id = "is_continue_weight", par_val = is_continue_weight
                });
                bll.UpdateParSetting(lst);
                Program.mo_ling            = mo_ling;
                Program.weight_model       = weight_model;
                Program.branch_no          = txt_branch_no.Text;
                Program.jh                 = txt_jh.Text;
                Program.input_cus_model    = input_cus_model;
                Program.print_count        = Conv.ToInt(txt_print_count.Text);
                Program.can_input_qty      = can_input_qty;
                Program.is_continue_weight = is_continue_weight;
                if (!SoftUpdate.PermissionsBalidation())
                {
                    IBLL.IClientBLL bll2   = new BLL.ClientBLL();
                    int             errId  = 0;
                    string          errMsg = "";
                    bll2.DownLoadOper(out errId, out errMsg);
                }

                var frm = new MsgForm("修改参数设置成功");
                frm.ShowDialog();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                new MsgForm(ex.GetMessage()).ShowDialog();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
        private void refreshData()
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //
                IBLL.ISaleData bll         = new BLL.SaleData();
                int            order_count = 0;
                decimal        total_amt   = 0;
                decimal        give_amt    = 0;
                string         order_key   = "SO";
                if (radioButton2.Checked)
                {
                    order_key = "PI";
                }
                var lst = bll.GetSaleSum(pnldate1.Text, pnldate2.Text, order_key, out order_count, out total_amt, out give_amt);

                lbl_order_count.Text = order_count.ToString();
                lbl_total_amt.Text   = total_amt.ToString("F2");
                lbl_give_amt.Text    = give_amt.ToString("F2");
                decimal no_pay = total_amt;
                if (lst.Count > 0)
                {
                    var cash_amt = lst.Where(d => d.pay_way == "A").Sum(d => d.pay_amount);
                    var wx_amt   = lst.Where(d => d.pay_way == "W").Sum(d => d.pay_amount);
                    var zfb_amt  = lst.Where(d => d.pay_way == "Z").Sum(d => d.pay_amount);
                    var ml_amt   = lst.Where(d => d.pay_way == "Y").Sum(d => d.pay_amount);

                    lbl_cash_amt.Text = cash_amt.ToString("F2");
                    lbl_wx_amt.Text   = wx_amt.ToString("F2");
                    lbl_zfb_amt.Text  = zfb_amt.ToString("F2");
                    lbl_ml_amt.Text   = ml_amt.ToString("F2");
                    no_pay            = no_pay - cash_amt - wx_amt - zfb_amt - ml_amt;
                }
                lbl_no_pay.Text = no_pay.ToString("F2");

                if (order_key == "SO")
                {
                    order_count = 0;
                    total_amt   = 0;
                    give_amt    = 0;
                    var lst2 = bll.GetSaleSum(pnldate1.Text, pnldate2.Text, "RI", out order_count, out total_amt, out give_amt);

                    if (order_count > 0)
                    {
                        groupBox1.Visible = true;
                    }

                    lbl_th_order_count.Text = order_count.ToString();
                    lbl_th_total_amt.Text   = total_amt.ToString("F2");
                    if (lst2.Count > 0)
                    {
                        var cash_amt = lst2.Where(d => d.pay_way == "A").Sum(d => d.pay_amount);
                        var wx_amt   = lst2.Where(d => d.pay_way == "W").Sum(d => d.pay_amount);
                        var zfb_amt  = lst2.Where(d => d.pay_way == "Z").Sum(d => d.pay_amount);
                        var ml_amt   = lst2.Where(d => d.pay_way == "Y").Sum(d => d.pay_amount);

                        lbl_th_cash_amt.Text = cash_amt.ToString("F2");
                        lbl_th_wx_amt.Text   = wx_amt.ToString("F2");
                        lbl_th_zfb_amt.Text  = zfb_amt.ToString("F2");
                        lbl_th_ml_amt.Text   = ml_amt.ToString("F2");
                    }
                }
            }
            catch (Exception e)
            {
                var frm = new MsgForm(e.Message);
                frm.ShowDialog();
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }