//����ͬ��
        private void syncDiffThread()
        {
            AssWebSrv.Service ws = new AssWebSrv.Service();
            ws.Url = SettingForm.sWebSrvUrl;
            //��ȡ���ش�ͬ������
            ShowStat(listBox1, "ͬ���������� ...");
            string sSql = "select * from sync_log where stat= '0' order by id asc";
            SQLiteDataReader reader = SQLiteHelper.ExecuteReader(sSql);
            if (!reader.HasRows)
            {
                ShowStat(listBox1, "�޴�ͬ�����ݣ�");
            }
            else
            {
                List<string> listSql = new List<string>();
                string sId = "0";
                while (reader.Read())
                {
                    sId = reader["id"].ToString();
                    string sTyp = reader["typ"].ToString();
                    string sSqlContent = reader["sql_content"].ToString();
                    string sAssId = reader["ass_id"].ToString();

                    ShowStat(listBox1, "����:" + sAssId + " " + sTyp);

                    listSql.Add(sSqlContent);

                    sSql = string.Format("insert into sync_log(typ,stat,sql_content,client_id,ass_id,cre_tm)values('{0}','{1}','{2}','{3}','{4}','{5}')",
            sTyp, "0", sSqlContent.Replace("'", "''"), SettingForm.sClientId, sAssId, LoginForm.getDateTime());
                    listSql.Add(sSql);
                    listSql.Add(sSql);
                }
                reader.Close();

                ShowStat(listBox1, "�ύ...");
                string sLastErr;
                bool bOK = ws.ExecuteNoQueryTran(listSql.ToArray(), out sLastErr);
                if (bOK)
                {
                    sSql = "update sync_log set stat = '1' where stat = '0' and id <= " + sId;
                    int nReslt = SQLiteHelper.ExecuteNonQuery(sSql,null);
                    if (nReslt > 0)
                    {
                        ShowStat(listBox1, "�ύOK!");
                    }
                    else
                    {
                        ShowStat(listBox1, "����״̬����ʧ��!" + SQLiteHelper.sLastErr);
                    }
                }
                else
                {
                    ShowStat(listBox1, "�ύʧ��!" + sLastErr);
                }
            }
            //��ȡ��������ͬ������
            ShowStat(listBox1, "");
            ShowStat(listBox1, "ͬ�������� ...");
            sSql = "select * from sync_log where client_id != '" + SettingForm.sClientId + "'  and id > " + SettingForm.sSyncMax + " order by id ASC";
            DataTable dt = ws.GetDataTableBySql(sSql);

            if (dt.Rows.Count == 0)
            {
                ShowStat(listBox1, "�޴�ͬ�����ݣ�");
            }
            else
            {
                List<string> listSql = new List<string>();
                string sMax = SettingForm.sSyncMax;
                foreach (DataRow dataRow in dt.Rows)
                {
                    sMax = dataRow["id"].ToString();
                    string sTyp = dataRow["typ"].ToString();
                    string sSqlContent = dataRow["sql_content"].ToString();
                    string sAssId = dataRow["ass_id"].ToString();
                    ShowStat(listBox1, "����:" + sAssId + " " + sTyp);
                    listSql.Add(sSqlContent);
                    Console.Out.WriteLine(sSqlContent);
                }
                listSql.Add(string.Format("update sys_parms set parm_val = '{0}' where parm_id = '{1}'", sMax, "sync_max"));

                ShowStat(listBox1, "�ύ...");
                bool bOK = SQLiteHelper.ExecuteNoQueryTran(listSql);
                if (bOK)
                {
                    SettingForm.sSyncMax = sMax;
                    ShowStat(listBox1, "�ύOK!");
                }
                else
                {
                    ShowStat(listBox1, "�ύʧ��!" + SQLiteHelper.sLastErr);
                    Console.Out.WriteLine(SQLiteHelper.sLastErr);
                    MessageBox.Show(SQLiteHelper.sLastErr);
                }
            }
            ShowStat(listBox1, "ͬ����ɣ�");
            ShowStat(listBox1, "finish-diff");
        }
        private void syncAllThread()
        {
            AssWebSrv.Service ws = new AssWebSrv.Service();
            ws.Url = SettingForm.sWebSrvUrl;
            //ͬ���ʲ��嵥
            syncFun(ws, "ass_list", "�ʲ��嵥");
            //ͬ����Ա����
            syncFun(ws, "emp", "��Ա����");
            //ͬ���˻���Ϣ
            syncFun(ws, "user", "�˻���Ϣ");
            //ͬ����ַ��Ϣ
            syncFun(ws, "addr", "��ַ��Ϣ");
            //ͬ���̵��嵥
            syncFun(ws, "inv_list", "�̵��嵥");
            //ͬ���ʲ���ʷ
            syncFun(ws, "ass_log", "�ʲ���ʷ");
            //ͬ��ϵͳ����
            syncFun(ws, "sys_parms", "ϵͳ����");

            //��������
            ShowStat(listBox1, "�������¼��ָ� ...");

            //��ȡͬ����
            string sSql = "select max(id) maxid from sync_log";
            DataTable dt = ws.GetDataTableBySql(sSql);
            string sSyncMax = "";
            if (dt != null)
            {
                sSyncMax = dt.Rows[0]["maxid"].ToString();
            }

            if (sSyncMax.Length == 0)
            {
                ShowStat(listBox1, "��ȡͬ����ʧ�ܣ�");
            }
            else
            {
                ShowStat(listBox1, "ͬ���Ÿ��£�" + sSyncMax);
                ShowStat(listBox1, "����ͬ������ɾ��");
                ShowStat(listBox1, "�ͻ���ID�ָ���" + SettingForm.sWebSrvIp);
                ShowStat(listBox1, "Web Service�ָ���" + SettingForm.sWebSrvIp);
                ShowStat(listBox1, "UDP IP�ָ���" + SettingForm.sUdpIp);
                ShowStat(listBox1, "UDP �˿ڻָ���" + SettingForm.sUdpPort);
            }

            List<string> listSql = new List<string>();
            listSql.Add(string.Format("update sys_parms set parm_val = '{0}' where parm_id = '{1}'", sSyncMax, "sync_max"));
            listSql.Add(string.Format("update sys_parms set parm_val = '{0}' where parm_id = '{1}'", SettingForm.sClientId, "client_id"));
            listSql.Add(string.Format("update sys_parms set parm_val = '{0}' where parm_id = '{1}'", SettingForm.sWebSrvIp, "websrv_ip"));
            listSql.Add(string.Format("update sys_parms set parm_val = '{0}' where parm_id = '{1}'", SettingForm.sUdpIp, "udp_ip"));
            listSql.Add(string.Format("update sys_parms set parm_val = '{0}' where parm_id = '{1}'", SettingForm.sUdpPort, "udp_port"));
            listSql.Add("delete from sync_log");

            bool bOK = SQLiteHelper.ExecuteNoQueryTran(listSql);
            if (bOK)
            {
                SettingForm.sSyncMax = sSyncMax;
            }

            ShowStat(listBox1, bOK ? "����OK��" : "�����ָ�ʧ�ܣ������²�����");
            ShowStat(listBox1, "--------------");

            ShowStat(listBox1, "ȫ��ͬ����ɣ�");
            ShowStat(listBox1, "");
            ShowStat(listBox1, "finish-all");
        }