public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bi_t_supcust_info") == false) { string sql = "create table bi_t_supcust_info(supcust_no varchar(20),supcust_flag varchar(1),sup_name varchar(50),sup_tel varchar(20),sup_pyname varchar(50)"; sql += ",display_flag varchar(1),credit_amt decimal(18,4),other1 varchar(60),cust_level varchar(1),is_retail varchar(10),primary key (supcust_no,supcust_flag)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bt_sysn_info") == false) { string sql; sql = "CREATE TABLE bt_sysn_info(table_name VARCHAR(50), sysn_time DATETIME) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("t_print_log") == false) { string sql; sql = "create table t_print_log(sheet_no varchar(20) primary key,print_count integer,oper_id varchar(20),oper_date datetime) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bi_t_branch_info") == false) { string sql; sql = "create table bi_t_branch_info(branch_no varchar(20) PRIMARY KEY,branch_name varchar(200)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("sa_t_operator_i") == false) { string sql = "create table sa_t_operator_i(oper_id varchar(20),oper_type varchar(20),oper_name varchar(50),oper_pw varchar(50)"; sql += ",oper_status varchar(1),update_time datetime,is_branch varchar(1),is_admin varchar(1),branch_no varchar(20)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bt_par_setting") == false) { string sql; sql = "create table bt_par_setting(par_id varchar(20), par_val varchar(50)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bi_t_item_cls") == false) { string sql; sql = "create table bi_t_item_cls(item_clsno varchar(20),item_flag varchar(1),item_clsname varchar(100),display_flag varchar(1),is_stop varchar(1)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("sys_t_system") == false) { string sql = "create table sys_t_system(sys_var_id varchar(20),sys_var_name varchar(40),sys_var_value varchar(250),is_changed varchar(2)"; sql += ",sys_var_desc varchar(100),sys_ver_flag varchar(1),update_time datetime) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("t_click_log") == false) { string sql; sql = "create table t_click_log(flow_id varchar(10),cus_id varchar(10),jh varchar(10),click_num varchar(10),oper_id varchar(20),oper_date datetime) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bi_t_cust_price") == false) { string sql = "create table bi_t_cust_price(cust_id varchar(20),item_no varchar(20),price_type varchar(1)"; sql += ",new_price decimal(18,4),top_price decimal(18,4),bottom_price decimal(18,4),last_price decimal(18,4)"; sql += ",top_sheet_no varchar(20),bottom_sheet_no varcahr(20),last_sheet_no varchar(20)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bi_t_sup_item") == false) { string sql = "create table bi_t_sup_item(sup_id varchar(20),item_no varchar(20),price decimal(18,4),top_price decimal(18,4)"; sql += ",bottom_price decimal(18,4),last_price decimal(18,4),top_sheet_no varchar(20),bottom_sheet_no varchar(20),last_sheet_no varchar(20)"; sql += ",spec_from datetime,spec_to datetime,spec_price decimal(18,4),item_status varchar(20)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("ic_t_inout_store_master") == false) { string sql = "create table ic_t_inout_store_master(sheet_no varchar(20) primary key,trans_no varchar(2),branch_no varchar(20)"; sql += ",supcust_no varchar(20),total_amount decimal(18,4),inout_amount decimal(18,4),approve_flag varchar(1),oper_date datetime"; sql += ",oper_id varchar(20),is_upload varchar(1),pay_way varchar(20)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("sm_t_salesheet_detail") == false) { string sql = "create table sm_t_salesheet_detail(sheet_no varchar(20),item_no varchar(20),item_subno varchar(20),item_name varchar(60),unit_no varchar(20),sale_price decimal(18,4)"; sql += ",real_price decimal(18,4),cost_price decimal(18,4),sale_qnty decimal(18,4),sale_money decimal(18,4),barcode varchar(20),sheet_sort integer,other3 varchar(60)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } //other3:是否赠送:1赠送 }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("ic_t_branch_stock") == false) { string sql; sql = "create table ic_t_branch_stock(branch_no varchar(20),item_no varchar(20),stock_qty decimal(18,4)"; sql += ",cost_price decimal(18,4),display_flag varchar(1),last_price decimal(18,4),fifo_price decimal(18,4)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("t_order_detail") == false) { string sql = "CREATE TABLE t_order_detail(flow_id INTEGER,sheet_no VARCHAR(20),item_no VARCHAR(20),item_subno VARCHAR(20),item_name VARCHAR(50)"; sql += ",unit_no varchar(20),oper_id VARCHAR(20),oper_date DATETIME,qty DECIMAL(18, 4),price DECIMAL(18, 4),amt DECIMAL(18, 4),jh VARCHAR(20)"; sql += ",cost_price decimal(18,4),branch_no varchar(20),cus_no varchar(20),sup_no varchar(20),approve_flag varchar(1),is_upload VARCHAR(1)"; sql += ",update_time datetime,update_oper varchar(20),source_price decimal(18, 4),discount decimal(18, 4),is_give varchar(1))"; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("ot_pay_flow") == false) { string sql; sql = "CREATE TABLE ot_pay_flow(sheet_no varchar(50),flow_id INTEGER,cus_no VARCHAR(20),oper_id VARCHAR(20),oper_date DATETIME"; sql += ",pay_way VARCHAR(50),sale_amount DECIMAL(18, 4),pay_amount DECIMAL(18, 4),old_amount DECIMAL(18, 4),ml DECIMAL(18, 4)"; sql += ",jh VARCHAR(20),approve_flag VARCHAR(1),remark VARCHAR(50),is_upload char(1)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("ic_t_inout_store_detail") == false) { string sql = "create table ic_t_inout_store_detail(sheet_no varchar(20),item_no varchar(20),item_subno varchar(20),item_name varchar(60),unit_no varchar(20),in_qty decimal(18,4)"; sql += ",orgi_price decimal(18,4),valid_price decimal(18,4),cost_price decimal(18,4),valid_date datetime,barcode varchar(20),sheet_sort integer,other3 varchar(60)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } //other3: 是否赠送:1赠送 }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("sm_t_salesheet") == false) { string sql = "create table sm_t_salesheet(sheet_no varchar(20) primary key,branch_no varchar(20),cust_no varchar(20),pay_way varchar(20)"; sql += ",coin_no varchar(50),real_amount decimal(18,4),total_amount decimal(18,4),paid_amount decimal(18,4),approve_flag varchar(1)"; sql += ",oper_id varchar(20),sale_man varchar(20),oper_date datetime,pay_date datetime,is_upload varchar(1),discount decimal(18,4)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } //discount整单折扣 }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("bi_t_item_info") == false) { string sql = "create table bi_t_item_info(item_no varchar(20) PRIMARY KEY,item_subno varchar(20),item_subname varchar(100),item_clsno varchar(20)"; sql += ",item_name varchar(100),item_brand varchar(20),item_brandname varchar(100),unit_no varchar(20),item_size varchar(20),product_area varchar(100)"; sql += ",barcode varchar(20),price decimal(18,4),base_price decimal(18, 4),sale_price decimal(18, 4),display_flag varchar(1),item_flag varchar(1)"; sql += ",base_price2 decimal(18, 4),base_price3 decimal(18, 4),base_price4 decimal(18, 4),base_price5 decimal(18, 4)) "; DB.IDB d = db; d.ExecuteScalar(sql, null); } }
public static void Upgrade(SQLiteByHandClose db) { if (db.ExistTable("sys_t_sheet_no") == false) { string sql; sql = "create table sys_t_sheet_no(sheet_id varchar(20),sheet_value integer) "; DB.IDB d = db; d.ExecuteScalar(sql, null); sql = "insert into sys_t_sheet_no values('PI',0)"; d.ExecuteScalar(sql, null); sql = "insert into sys_t_sheet_no values('SO',0)"; d.ExecuteScalar(sql, null); sql = "insert into sys_t_sheet_no values('RI',0)"; d.ExecuteScalar(sql, null); } }
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); } }