Exemplo n.º 1
0
        public static bool InsertMandate(MandateInfo mandate, List <SampleInfo> sampleList, ref string err)
        {
            string          MandateSql   = GSqlSentence.GetInsertInfoByD <MandateInfo>(mandate, "MandateInfo");
            string          sampleSql    = GSqlSentence.GetInsertByList <SampleInfo>(sampleList, "SampleInfo");
            List <TestItem> testItemList = GetItemIDs(mandate.TestingItems, mandate.YYCode);
            string          testItemSql  = GSqlSentence.GetInsertByList <TestItem>(testItemList, "TestItem");
            string          sql          = "select count(*) from MandateInfo where YYCode='" + mandate.YYCode + "'";

            try
            {
                if ((int)SQLBase.ExecuteScalar(sql) > 0)
                {
                    err = "该委托单已添加";
                    return(false);
                }


                if (SQLBase.ExecuteNonQuery(MandateSql) > 0)
                {
                    if (!UpdateYYCode(mandate.YYCode))
                    {
                        err = "预约号更新失败";
                        return(false);
                    }

                    if (sampleList.Count > 0)
                    {
                        if (SQLBase.ExecuteNonQuery(sampleSql) <= 0)
                        {
                            err = "样品信息添加失败";
                            return(false);
                        }
                    }
                    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 = "委托信息添加失败";
            }
            catch (Exception e)
            {
                err = e.Message;
            }


            return(false);
        }
Exemplo n.º 2
0
        public static MandateInfo GetMandateInfo(string YYCode)
        {
            string      sql         = "select YYCode, MCode, ClienName, ClienTel, ClienAddress, PostalCode, ProName, SourceWay, SamplePeople, SampleTime, Manufacturer, Document, Secrecy, TestingBasis, TestingItems, DemandFinishDate, PickupMethod, MailingAddress, Remark, SampleDisposition, MandatePeople, AcceptTime, AcceptPeople, Charge, SReceiveState, State, CreateTime, CreateUser, Validate,RepealReason, TestType, Provinces from MandateInfo where YYCode='" + YYCode + "'";
            DataTable   dt          = SQLBase.FillTable(sql);
            MandateInfo mandateInfo = new MandateInfo();

            if (dt.Rows.Count > 0)
            {
                mandateInfo.YYCode            = dt.Rows[0]["YYCode"].ToString();
                mandateInfo.MCode             = dt.Rows[0]["MCode"].ToString();
                mandateInfo.ClienName         = dt.Rows[0]["ClienName"].ToString();
                mandateInfo.ClienTel          = dt.Rows[0]["ClienTel"].ToString();
                mandateInfo.ClienAddress      = dt.Rows[0]["ClienAddress"].ToString();
                mandateInfo.PostalCode        = dt.Rows[0]["PostalCode"].ToString();
                mandateInfo.ProName           = dt.Rows[0]["ProName"].ToString();
                mandateInfo.SourceWay         = dt.Rows[0]["SourceWay"].ToString();
                mandateInfo.SamplePeople      = dt.Rows[0]["SamplePeople"].ToString();
                mandateInfo.SampleTime        = Convert.ToDateTime(dt.Rows[0]["SampleTime"]).ToString("yyyy-MM-dd");
                mandateInfo.Manufacturer      = dt.Rows[0]["Manufacturer"].ToString();
                mandateInfo.Document          = dt.Rows[0]["Document"].ToString();
                mandateInfo.Secrecy           = dt.Rows[0]["Secrecy"].ToString();
                mandateInfo.TestingBasis      = dt.Rows[0]["TestingBasis"].ToString();
                mandateInfo.TestingItems      = dt.Rows[0]["TestingItems"].ToString();
                mandateInfo.DemandFinishDate  = Convert.ToDateTime(dt.Rows[0]["DemandFinishDate"]).ToString("yyyy-MM-dd");
                mandateInfo.PickupMethod      = dt.Rows[0]["PickupMethod"].ToString();
                mandateInfo.MailingAddress    = dt.Rows[0]["MailingAddress"].ToString();
                mandateInfo.Remark            = dt.Rows[0]["Remark"].ToString();
                mandateInfo.SampleDisposition = dt.Rows[0]["SampleDisposition"].ToString();
                mandateInfo.MandatePeople     = dt.Rows[0]["MandatePeople"].ToString();
                mandateInfo.Charge            = Convert.ToDouble(dt.Rows[0]["Charge"]);
                mandateInfo.AcceptTime        = dt.Rows[0]["AcceptTime"].ToString();
                mandateInfo.AcceptPeople      = dt.Rows[0]["AcceptPeople"].ToString();
                mandateInfo.SReceiveState     = Convert.ToInt32(dt.Rows[0]["SReceiveState"]);
                mandateInfo.State             = Convert.ToInt32(dt.Rows[0]["State"]);
                mandateInfo.CreateTime        = dt.Rows[0]["CreateTime"].ToString();
                mandateInfo.CreateUser        = dt.Rows[0]["CreateUser"].ToString();
                mandateInfo.Validate          = dt.Rows[0]["Validate"].ToString();
                mandateInfo.RepealReason      = dt.Rows[0]["RepealReason"].ToString();
                mandateInfo.TestType          = dt.Rows[0]["TestType"].ToString();
                mandateInfo.Provinces         = dt.Rows[0]["Provinces"].ToString();
            }
            return(mandateInfo);
        }
Exemplo n.º 3
0
 public static bool UpdateMandate(MandateInfo mandate, List <SampleInfo> sampleList, ref string err)
 {
     return(MandateInfoPro.UpdateMandate(mandate, sampleList, ref err));
 }
Exemplo n.º 4
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);
        }