示例#1
0
 private void btnDiff_Click(object sender, EventArgs e)
 {
     if (dgvApplyInfo.Rows.Count > 0)
     {
         foreach (DataGridViewRow dr in dgvApplyInfo.Rows)
         {
             Boolean      boolDiff = false;
             AccessHelper ah       = new AccessHelper();
             string       sql      = "select * from ApplicationDetail where TransNO='" + dr.Cells["TransNo"].Value.ToString() + "' ";
             DataTable    dtsql    = ah.SelectToDataTable(sql);
             if (dr.Cells["FinalExceptionFilter"].Value.ToString() == "异常")
             {
                 for (int x = 0; x < dtsql.Rows.Count; x++)
                 {
                     AccessHelper tempah    = new AccessHelper();
                     string       tempsql   = "select * from ApplicationDetail where TransNO='" + dr.Cells["TransNo"].Value.ToString() + "' and ItemID='" + dtsql.Rows[x]["ItemID"].ToString() + "' ";
                     DataTable    dttempsql = tempah.SelectToDataTable(tempsql);
                     tempah.Close();
                     if (dttempsql.Rows.Count > 1)
                     {
                         boolDiff = true;
                     }
                     else
                     {
                         AccessHelper tempah2  = new AccessHelper();
                         string       tempsql2 = "update ApplicationDetail set IsRepetition=0 where TransNO='" + dr.Cells["TransNo"].Value.ToString() + "' and ItemID='" + dtsql.Rows[x]["ItemID"].ToString() + "' ";
                         tempah2.ExecuteSQLNonquery(tempsql2);
                         tempah2.Close();
                     }
                 }
             }
             for (int i = 0; i < dtsql.Rows.Count; i++)
             {
                 if (int.Parse(dtsql.Rows[i]["IsSuccess"].ToString()) != 1)
                 {
                     boolDiff = true;
                 }
             }
             if (boolDiff == false)
             {
                 AccessHelper tempah  = new AccessHelper();
                 string       tempsql = "update ApplicationInfo set FinalException=0 where TransNO='" + dr.Cells["TransNo"].Value.ToString() + "' ";
                 tempah.ExecuteSQLNonquery(tempsql);
                 tempah.Close();
             }
             else
             {
                 AccessHelper tempah  = new AccessHelper();
                 string       tempsql = "update ApplicationInfo set FinalException=1 where TransNO='" + dr.Cells["TransNo"].Value.ToString() + "' ";
                 tempah.ExecuteSQLNonquery(tempsql);
                 tempah.Close();
             }
             ah.Close();
         }
         GetApplicationDetail();
         MessageBox.Show("计算完成!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#2
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     strConnstring = XMLHelper.strGetConnectString().Split(';')[1].ToString().Split('=')[1].ToString();
     strlock       = strConnstring.Substring(0, strConnstring.LastIndexOf("\\") + 1) + "TransferLock";
     if (!File.Exists(strlock))
     {
         try
         {
             string       strTSQL = "select * from SetupConfig";
             AccessHelper ahTSQL  = new AccessHelper();
             DataTable    dtTSQL  = ahTSQL.SelectToDataTable(strTSQL);
             ahTSQL.Close();
             if (txtName.Text.ToLower() == "administrator" || GetComputerName().Substring(0, 3) == "OC1")
             {
                 UpdateDataBase();
             }
             if (strVersion == Application.ProductVersion)
             {
                 LoginProcess();
             }
             else if (strVersion == "" || CompareVersion(Application.ProductVersion, strVersion))
             {
                 if (GetComputerName().Substring(0, 3) == "OC1")
                 {
                     string       strSQL = "update SetupConfig set Version='" + Application.ProductVersion + "' ";
                     AccessHelper ah     = new AccessHelper();
                     ah.ExecuteSQLNonquery(strSQL);
                     ah.Close();
                 }
                 LoginProcess();
             }
             else
             {
                 MessageBox.Show("系统版本过低,请先升级后再重新登录使用!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             if (txtName.Text.ToLower() == "administrator" || GetComputerName().Substring(0, 3) == "OC1")
             {
                 MessageBox.Show("数据库损坏,点击确定后,系统将尝试自动修复,期间请勿操作!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 string strResult = RepairAccess(strConnstring);
                 if (strResult.Substring(0, 5) != "Error")
                 {
                     MessageBox.Show("数据库修复完成,请关闭系统,并重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("数据库修复失败::" + strResult, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
             else
             {
                 MessageBox.Show("数据库损坏,稍后将由上海办公室修复,请稍后重新登录!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     else
     {
         string strRepairUser = File.ReadAllText(strlock);
         MessageBox.Show("登陆失败::数据库正在计算机: " + strRepairUser + " 启用自动修复中,请稍后重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#3
0
        private void btnDataProcess_Click(object sender, EventArgs e)
        {
            AccessHelper ah = new AccessHelper();

            foreach (DataRow dr in dtStaDetail.Rows)
            {
                string    strCtrlID     = "";
                int       intNum        = int.Parse(dr["num"].ToString());
                int       intCI         = 1;
                int       intCurrentNum = 1;
                int       intTotalCount = 0;
                double    douTotalPrice = 0.00;
                string    strSQL        = "select * from applicationdetail where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                DataTable dtDataDetail  = ah.SelectToDataTable(strSQL);
                strSQL = "select * from ApplicationInfo where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                DataTable dtDataInfo   = ah.SelectToDataTable(strSQL);
                string    strOriCtrlID = "Auto" + DateTime.Now.ToString("HHmmssfff") + dtDataInfo.Rows[0]["Applicants"].ToString().Substring(0, 1);
                strCtrlID = strOriCtrlID;
                DataTable AddAppInfoDT   = applicationInfo.SelectApplicationByCtrlID("0");
                DataTable AddAppDetailDT = applicationDetail.SelectAppDetailByCtrlID("0");
                DataRow   drInfo         = AddAppInfoDT.NewRow();
                DataRow   drDetail       = AddAppDetailDT.NewRow();
                drInfo = dtDataInfo.Rows[0];

                foreach (DataRow drIN in dtDataDetail.Rows)
                {
                    drDetail = drIN;
                    if (intCurrentNum <= 20)
                    {
                        intCurrentNum++;
                        drInfo["CtrlID"]   = strCtrlID;
                        drDetail["CtrlID"] = strCtrlID;
                        intTotalCount     += (int)drDetail["App_Count"];
                        douTotalPrice     += ((int)drDetail["App_Count"]) * ((double.Parse(drDetail["Price"].ToString())));
                        AddAppDetailDT.Rows.Add(drDetail.ItemArray);
                    }
                    else
                    {
                        drInfo["TotalCount"] = intTotalCount;
                        drInfo["TotalPrice"] = douTotalPrice;
                        AddAppInfoDT.Rows.Add(drInfo.ItemArray);
                        applicationInfo.SubmitApplicationInfo(AddAppInfoDT);
                        applicationDetail.SubmitApplicationDetail(AddAppDetailDT);

                        intCurrentNum = 1;
                        intTotalCount = 0;
                        douTotalPrice = 0.00;
                        strCtrlID     = strOriCtrlID + intCI.ToString();
                        intCI++;
                        AddAppInfoDT.Clear();
                        AddAppDetailDT.Clear();
                        //drInfo = AddAppInfoDT.NewRow();
                        //drDetail = AddAppDetailDT.NewRow();
                        //drInfo = dtDataInfo.Rows[0];

                        intCurrentNum++;
                        drInfo["CtrlID"]   = strCtrlID;
                        drDetail["CtrlID"] = strCtrlID;
                        intTotalCount     += (int)drDetail["App_Count"];
                        douTotalPrice     += ((int)drDetail["App_Count"]) * ((double.Parse(drDetail["Price"].ToString())));
                        AddAppDetailDT.Rows.Add(drDetail.ItemArray);
                    }
                }
                if (AddAppDetailDT.Rows.Count > 0)
                {
                    drInfo["TotalCount"] = intTotalCount;
                    drInfo["TotalPrice"] = douTotalPrice;
                    AddAppInfoDT.Rows.Add(drInfo.ItemArray);
                    applicationInfo.SubmitApplicationInfo(AddAppInfoDT);
                    applicationDetail.SubmitApplicationDetail(AddAppDetailDT);

                    intCurrentNum = 1;
                    intTotalCount = 0;
                    douTotalPrice = 0.00;
                    //strCtrlID = strOriCtrlID + intCI.ToString();
                    //intCI++;
                    AddAppInfoDT.Clear();
                    AddAppDetailDT.Clear();
                }
                strSQL = "update applicationdetail set isdelete=1 where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                ah.ExecuteSQLNonquery(strSQL);
                strSQL = "update ApplicationInfo set isdelete=1 where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                ah.ExecuteSQLNonquery(strSQL);
            }
            ah.Close();
            MessageBox.Show("处理完成!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            frmDataProcessing_Load(null, null);
        }
示例#4
0
 public void ExecuteSqlQuery(DataRow dr)
 {
     //string sqlString = string.Format("select * from AccessQueue order by [ID] asc");
     //DataTable SqlQuery = SelectToDataTable(sqlString);
     try
     {
         AccessHelper ah = new AccessHelper();
         //foreach (DataRow dr in SqlQuery.Rows)
         //{
         if (dr["operation"].ToString() == "确认唯一码")
         {
             try
             {
                 string    str    = string.Format("select * from ApplicationInfo where IsDelete = 0 and AppState>5 and [TransNo]='{0}'  ", dr["TransNo"].ToString());
                 DataTable Result = ah.SelectToDataTable(str);
                 if (Result.Rows.Count > 0)
                 {
                     if (dr["Buy"].ToString() == "1")//重复购买
                     {
                         bool      successed = false;
                         string    selectSql = string.Format("select * from ApplicationDetail where  [ID] = {0}", dr["DetailID"]);
                         DataTable dt        = ah.SelectToDataTable(selectSql);
                         if (dt.Rows.Count > 0)
                         {
                             dt.Rows[0]["ID"]           = DBNull.Value;
                             dt.Rows[0]["IsRepetition"] = 1;
                             StringBuilder insertSql = new StringBuilder();
                             insertSql.Append("Insert into [ApplicationDetail]");
                             insertSql.Append(" ([CodeID],[TransNo],[ItemID],[Detail],[Price],[MoneyUnit],[Count],[IsDelete],[SelforGift],[ApprovalCount],[ApprovalDiscount],[FinalPrice],[Recipient],[Relationship],[Reason],[IsSuccess],[IsRepetition]) ");
                             insertSql.Append("values");
                             insertSql.AppendFormat(" ('{0}','{1}','{2}','{3}',{4},{5},{6},{7},{8},{9},{10},{11},'{12}','{13}','{14}',{15},{16})", dt.Rows[0]["CodeID"], dt.Rows[0]["TransNo"], dt.Rows[0]["ItemID"], dt.Rows[0]["Detail"], dt.Rows[0]["Price"], dt.Rows[0]["MoneyUnit"], dt.Rows[0]["Count"], dt.Rows[0]["IsDelete"], dt.Rows[0]["SelforGift"], dt.Rows[0]["ApprovalCount"], dt.Rows[0]["ApprovalDiscount"], dt.Rows[0]["FinalPrice"], dt.Rows[0]["Recipient"], dt.Rows[0]["Relationship"], dt.Rows[0]["Reason"], dt.Rows[0]["IsSuccess"], dt.Rows[0]["IsRepetition"]);
                             successed = ah.ExecuteSQLNonquery(insertSql.ToString());
                             if (successed)
                             {
                                 string delSql = string.Format("delete from AccessQueue where [ID]={0}", dr["ID"]);//执行成功后删除队列
                                 ExecuteSQLNonquery(delSql);
                             }
                         }
                         string excString = string.Format("Update ApplicationInfo Set FinalException=1 where IsDelete = 0 and TransNo='{0}'", dr["TransNo"].ToString());
                         ah.ExecuteSQLNonquery(excString);
                     }
                     else
                     {
                         bool   successed = false;
                         string exeSql    = dr["SqlStr"].ToString();
                         successed = ah.ExecuteSQLNonquery(exeSql);//执行sql
                         if (successed)
                         {
                             string delSql = string.Format("delete from AccessQueue where [ID]={0}", dr["ID"]);//执行成功后删除队列
                             ExecuteSQLNonquery(delSql);
                         }
                     }
                 }
                 else
                 {
                     bool   successed = false;
                     string exeSql    = dr["SqlStr"].ToString();
                     successed = ah.ExecuteSQLNonquery(exeSql);//执行sql
                     if (successed)
                     {
                         string delSql = string.Format("delete from AccessQueue where [ID]={0}", dr["ID"]);//执行成功后删除队列
                         ExecuteSQLNonquery(delSql);
                     }
                 }
             }
             catch
             {
             }
         }
         else
         {
             bool   successed = false;
             string exeSql    = dr["SqlStr"].ToString();
             successed = ah.ExecuteSQLNonquery(exeSql);//执行sql
             if (successed)
             {
                 string delSql = string.Format("delete from AccessQueue where [ID]={0}", dr["ID"]);//执行成功后删除队列
                 ExecuteSQLNonquery(delSql);
             }
         }
         //}
         ah.Close();
     }
     catch (Exception ex)
     {
     }
 }
示例#5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            strConnstring = XMLHelper.strGetConnectString().Split(';')[1].ToString().Split('=')[1].ToString();
            strlock       = strConnstring.Substring(0, strConnstring.LastIndexOf("\\") + 1) + "PurchaseLock";
            string url = strConnstring.Substring(0, strConnstring.LastIndexOf("\\") + 1) + "DBCache\\";

            if (!Directory.Exists(url))         //如果不存在就创建file文件夹                 
            {
                Directory.CreateDirectory(url); //创建该文件夹 
            }
            strTempDB = url + GetASCII(txtName.Text) + ".accdb";
            CacheHelper.ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strTempDB;
            if (!File.Exists(strTempDB))
            {
                string strNullDB = ".\\null.accdb";
                if (File.Exists(strNullDB))
                {
                    try
                    {
                        File.Copy(strNullDB, strTempDB, true);
                    }
                    catch
                    {
                        MessageBox.Show("临时文件夹创建失败!数据库目录权限不足!系统运行异常!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("系统文件null.accdb丢失!请重新安装!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            if (!File.Exists(".\\内购SQLQueue.accdb"))
            {
                MessageBox.Show("系统文件内购SQLQueue.accdb丢失!请重新安装!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    //SqlQueue sq = new SqlQueue();
                    //sq.InsertQuery("select * from ")
                }
                catch
                {
                }
            }
            if (!File.Exists(strlock) && File.Exists(strTempDB))
            {
                try
                {
                    string       strTSQL = "select * from SetupConfig";
                    AccessHelper ahTSQL  = new AccessHelper();
                    DataTable    dtTSQL  = ahTSQL.SelectToDataTable(strTSQL);
                    ahTSQL.Close();
                    if (GetComputerName().Substring(0, 3) == "OC1" || txtName.Text.ToLower() == "administrator")
                    {
                        UpdateDataBase();
                    }
                    if (strVersion == Application.ProductVersion)
                    {
                        LoginProcess();
                    }
                    else if (strVersion == "" || CompareVersion(Application.ProductVersion, strVersion))
                    {
                        if (GetComputerName().Substring(0, 3) == "OC1" || txtName.Text.ToLower() == "administrator")
                        {
                            string       strSQL = "update SetupConfig set Version='" + Application.ProductVersion + "' ";
                            AccessHelper ah     = new AccessHelper();
                            ah.ExecuteSQLNonquery(strSQL);
                            ah.Close();
                        }
                        LoginProcess();
                    }
                    else
                    {
                        MessageBox.Show("系统版本过低,请先升级后再重新登录使用!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    if (txtName.Text.ToLower() == "administrator" || GetComputerName().Substring(0, 3) == "OC1")
                    {
                        MessageBox.Show("数据库损坏,点击确定后,系统将尝试自动修复,期间请勿操作!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        string strResult = RepairAccess(strConnstring);
                        if (strResult.Substring(0, 5) != "Error")
                        {
                            MessageBox.Show("数据库修复完成,请关闭系统,并重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("数据库修复失败::" + strResult, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("数据库损坏,稍后将由上海办公室修复,请稍后重新登录!::" + ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else
            {
                if (File.Exists(strTempDB))
                {
                    string strRepairUser = File.ReadAllText(strlock);
                    MessageBox.Show("登陆失败::数据库正在计算机: " + strRepairUser + " 启用自动修复中,请稍后重新登录!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("登陆失败::远端缓存库联络失败,请联系管理员!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }