예제 #1
0
        public static bool UpdatePayInfo(PayInfo payInfo, string YYCode, ref string err)
        {
            string sql   = "select PayType from PayInfo where payId='" + payInfo.PayId + "'";
            string pType = SQLBase.ExecuteScalar(sql).ToString();

            string paySql = GSqlSentence.GetUpdateInfoByD <PayInfo>(payInfo, "PayId", "PayInfo");

            if (SQLBase.ExecuteNonQuery(paySql) <= 0)
            {
                err = "缴费信息更新失败";
                return(false);
            }
            sql = "update ConsumptionInfo set type=" + payInfo.PayType + " where PayId='" + payInfo.PayId + "'";
            if (SQLBase.ExecuteNonQuery(sql) <= 0)
            {
                err = "消费信息更新失败";
                return(false);
            }

            if (pType != payInfo.PayType && payInfo.PayType == "2")
            {
                sql = "select ClienName from ClientPayInfo where ClienName = '" + payInfo.PayCompany + "'";
                DataTable dt = SQLBase.FillTable(sql);
                if (dt.Rows.Count > 0)
                {
                    sql = "update ClientPayInfo set Money = Money+" + payInfo.PayMoney + " where ClienName = '" + payInfo.PayCompany + "'";
                    if (SQLBase.ExecuteNonQuery(sql) <= 0)
                    {
                        return(false);
                    }
                }
                else
                {
                    sql = "insert into ClientPayInfo(ClienName,Money) values('" + payInfo.PayCompany + "'," + payInfo.PayMoney + ")";
                    if (SQLBase.ExecuteNonQuery(sql) <= 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #2
0
        public static bool UpdateMandate(MandateInfo mandate, List <SampleInfo> sampleList, ref string err)
        {
            string MandateSql = GSqlSentence.GetUpdateInfoByD(mandate, "YYCode", "MandateInfo");

            if (mandate.MCode != "" && mandate.MCode != null)
            {
                string MCode  = mandate.MCode;
                int    number = 0;
                for (int i = 0; i < sampleList.Count; i++)
                {
                    string sampleCode = "";
                    if (sampleList[i].Number > 1)
                    {
                        string strartStr = (number + 1).ToString();
                        string endStr    = (number + sampleList[i].Number).ToString();
                        if (strartStr.Length < 2)
                        {
                            strartStr = "0" + strartStr;
                        }
                        if (endStr.Length < 2)
                        {
                            endStr = "0" + endStr;
                        }
                        sampleCode = MCode + "-" + strartStr + "-" + endStr;
                        number     = Convert.ToInt32(endStr);
                    }
                    else
                    {
                        if ((number + 1).ToString().Length > 2)
                        {
                            sampleCode = MCode + "-" + (number + 1);
                        }
                        else
                        {
                            string result = "00" + (number + 1);
                            sampleCode = MCode + "-" + result.Substring(result.Length - 2, 2);
                        }
                        number += 1;
                    }
                    sampleList[i].SampleCode = sampleCode;
                }
            }

            string sampleSql = GSqlSentence.GetInsertByList <SampleInfo>(sampleList, "SampleInfo");

            List <TestItem> testItemList = GetItemIDs(mandate.TestingItems, mandate.YYCode);
            string          testItemSql  = GSqlSentence.GetInsertByList <TestItem>(testItemList, "TestItem");
            string          sql          = "";

            if (SQLBase.ExecuteNonQuery(MandateSql) > 0)
            {
                sql = "delete SampleInfo where YYCode='" + mandate.YYCode + "'";
                if (SQLBase.ExecuteNonQuery(sql) >= 0)
                {
                    if (sampleList.Count > 0)
                    {
                        if (SQLBase.ExecuteNonQuery(sampleSql) <= 0)
                        {
                            err = "样品信息添加失败";
                            return(false);
                        }
                    }
                }
                sql = "delect TestItem where YYCode='" + mandate.YYCode + "'";
                if (SQLBase.ExecuteNonQuery(sql) >= 0)
                {
                    if (testItemList.Count > 0)
                    {
                        if (SQLBase.ExecuteNonQuery(testItemSql) <= 0)
                        {
                            err = "检测项目添加失败";
                            return(false);
                        }
                    }
                }
                string content = "修改委托单信息";
                if (!insertLog(mandate.YYCode, content))
                {
                    err = "更新日志失败";
                    return(false);
                }

                return(true);
            }

            err = "委托信息更新失败";


            return(false);
        }