Esempio n. 1
0
        private void ThreadEnd(int errId, string errMsg)
        {
            if (errId == 0 || errId == -1)
            {
                Program.item_count      = 0;
                Program.sup_count       = 0;
                Program.cus_price_count = 0;
                Program.sup_price_count = 0;

                is_finish   = true;
                pro.Visible = false;

                if (errId == 0)
                {
                    errMsg = "下载成功";
                }
                MsgForm frm = new MsgForm(errMsg);
                frm.ShowDialog();
                this.Close();
            }
            else
            {
                lbl_msg.Text = errMsg;
                if (errId == -2)
                {
                    lbl_msg.ForeColor = Color.Red;
                }
                else
                {
                    lbl_msg.ForeColor = Color.Gray;
                }
            }
        }
Esempio n. 2
0
 private void btn_ok_Click(object sender, EventArgs e)
 {
     if (is_finish)
     {
         if (!Program.is_connect)
         {
             (new MsgForm("网络异常")).ShowDialog();
             return;
         }
         is_finish   = false;
         pro.Visible = true;
         downThread ins = new downThread();
         ins.chk1    = c1;
         ins.chk2    = c2;
         ins.chk3    = c3;
         ins.chk4    = c4;
         ins.chk5    = c5;
         ins.mainCon = this;
         ins.deleg   = ThreadEnd;
         System.Threading.Thread th = new System.Threading.Thread(ins.down);
         th.Start();
     }
     else
     {
         MsgForm frm = new MsgForm("正在下载数据,请稍候……");
         frm.ShowDialog();
     }
 }
Esempio n. 3
0
 public void EndCallHandler(int errId, string errMsg)
 {
     try
     {
         if (errId == 99)
         {
             lbl_tip.Text = errMsg;
         }
         else if (errId == 0)
         {
             var frm = new MsgForm("上传单据成功");
             frm.ShowDialog();
             this.flag = 1;
         }
         else
         {
             var frm = new MsgForm(errMsg);
             frm.ShowDialog();
             this.flag = 1;
         }
     }
     catch (Exception ex)
     {
         Log.writeLog("frmDownLoad ->EndCallHandler()", ex.ToString(), null);
     }
 }
Esempio n. 4
0
 private void label14_Click(object sender, EventArgs e)
 {
     try
     {
         decimal ss = Conv.ToDecimal(lbl.Text.Trim());
         if (ss <= 0)
         {
             throw new Exception("付款金额不正确!");
         }
         if (ss - ys != 0)
         {
             var frm = new YesNoForm("付款金额与应付金额不一致,是否继续?");
             if (frm.ShowDialog() == DialogResult.No)
             {
                 return;
             }
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     catch (Exception ex)
     {
         MsgForm frm = new MsgForm(ex.GetMessage());
         frm.ShowDialog();
     }
 }
Esempio n. 5
0
 private void btn_cancel_Click(object sender, EventArgs e)
 {
     if (is_finish)
     {
         this.Close();
     }
     else
     {
         MsgForm frm = new MsgForm("正在下载数据,请稍候……");
         frm.ShowDialog();
     }
 }
Esempio n. 6
0
 private void label14_Click(object sender, EventArgs e)
 {
     try
     {
         decimal sk = Conv.ToDecimal(lbl.Text.Trim());
         decimal ss = Conv.ToDecimal(lbss.Text.Trim());
         decimal zk = Conv.ToDecimal(this.zk.Text);
         decimal zl = Conv.ToDecimal(this.lblzl.Text);
         if (sk <= 0)
         {
             new MsgForm("收款金额不正确!").ShowDialog();
             return;
         }
         if (zk < 0 || zk > 1)
         {
             new MsgForm("折扣必须在[0,1]之间!").ShowDialog();
             return;
         }
         if (sk - ss < 0)
         {
             var frm = new YesNoForm("收款金额小于应收,是否继续?");
             if (frm.ShowDialog() == DialogResult.No)
             {
                 return;
             }
         }
         if (zl >= 100)
         {
             new MsgForm("找零必须小于100").ShowDialog();
             return;
         }
         if (zl >= 0.1M)
         {
             ZLForm frm2 = new ZLForm(zl.ToString("0.00"));
             frm2.ShowDialog();
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     catch (Exception ex)
     {
         MsgForm frm = new MsgForm(ex.GetMessage());
         frm.ShowDialog();
     }
 }
Esempio n. 7
0
        private void label14_Click(object sender, EventArgs e)
        {
            if (txt_pwd2.Text.Length == 0)
            {
                var frm = new MsgForm("请正确输入密码");
                frm.ShowDialog();
                txt_pwd2.Focus();
            }
            else
            {
                try
                {
                    IBLL.IClientBLL bll     = new BLL.ClientBLL();
                    string          old_pwd = txt_pwd1.Text;
                    string          pwd     = txt_pwd2.Text;
                    Helper.sec      sec     = new Helper.sec();
                    if (old_pwd != "")
                    {
                        old_pwd = sec.des(old_pwd);
                    }
                    if (pwd != "")
                    {
                        pwd = sec.des(pwd);
                    }
                    var res = bll.ChangePwd(Program.branch_no, Program.oper_id, old_pwd, pwd);
                    if (res)
                    {
                        IBLL.IOper bll2 = new BLL.Oper();
                        bll2.UpdatePwd(Program.branch_no, Program.oper_id, pwd);

                        var frm = new MsgForm("修改密码成功");
                        frm.ShowDialog();
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    var frm = new MsgForm(ex.GetMessage());
                    frm.ShowDialog();
                }
            }
        }
Esempio n. 8
0
 private void ShowLine()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         this.dataGridView1.Rows.Clear();
         var lst = lines.OrderByDescending(d => d.flow_id).Skip((sale_page_no - 1) * sale_page_size).Take(sale_page_size).OrderBy(d => d.flow_id).ToList();
         foreach (Model.t_order_detail item in lst)
         {
             var index = this.dataGridView1.Rows.Add();
             var row   = this.dataGridView1.Rows[index];
             row.Tag            = item.flow_id;
             row.Cells[0].Value = item.flow_id.ToString();
             row.Cells[1].Value = item.item_name;
             row.Cells[2].Value = item.unit_no;
             row.Cells[3].Value = item.qty.ToString("F3");
             row.Cells[4].Value = item.price.ToString("F2");
             row.Cells[5].Value = (item.qty * item.price).ToString("F2");
             if (item.is_give == "1")
             {
                 row.Cells[5].Style.Font = new Font("SimSun", 10.5F, FontStyle.Strikeout);
             }
         }
         decimal sum_qty  = lines.Sum(d => d.qty);
         decimal sum_amt  = lines.Sum(d => d.qty * d.price);
         decimal give_amt = lines.Where(d => d.is_give == "1").Sum(d => d.qty * d.source_price);
         lbl_sum_qty.Text   = sum_qty.ToString("F3");
         lbl_sum_amt.Text   = give_amt.ToString("F2");
         lbl_total_amt.Text = sum_amt.ToString("F2");
     }
     catch (Exception ex)
     {
         var frm = new MsgForm(ex.GetMessage());
         frm.ShowDialog();
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Esempio n. 9
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;
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
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;
            }
        }
Esempio n. 12
0
        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;
            }
        }