Example #1
0
        public static int InsertDScrapInfo(DScrapInfo Scrap, ref string a_strErr)
        {
            int      intInsert = 0;
            int      intUpdate = 0;
            SQLTrans sqlTrans  = new SQLTrans();

            sqlTrans.Open("SupplyCnn");
            string strInsert = GSqlSentence.GetInsertInfoByD <DScrapInfo>(Scrap, "tk_DScrapInfo");
            string strUpdate = "update tk_DevicsBas set state = '-1' where ECode = '" + Scrap.StrECode + "'";

            try
            {
                if (strInsert != "")
                {
                    intInsert = sqlTrans.ExecuteNonQuery(strInsert, CommandType.Text, null);
                }
                if (strUpdate != "")
                {
                    intUpdate = sqlTrans.ExecuteNonQuery(strUpdate, CommandType.Text, null);
                }
                sqlTrans.Close(true);
            }
            catch (SqlException e)
            {
                sqlTrans.Close(false);
                a_strErr = e.Message;
                return(-1);
            }

            return(intInsert + intUpdate);
        }
Example #2
0
        public static int InsertRativeSource(RativeSource Rsource, ref string a_strErr)
        {
            int      intInsert = 0;
            SQLTrans sqlTrans  = new SQLTrans();

            sqlTrans.Open("SupplyCnn");
            string strInsert = GSqlSentence.GetInsertInfoByD <RativeSource>(Rsource, "tk_RativeSource");

            try
            {
                if (strInsert != "")
                {
                    intInsert = sqlTrans.ExecuteNonQuery(strInsert, CommandType.Text, null);
                }
                sqlTrans.Close(true);
            }
            catch (SqlException e)
            {
                sqlTrans.Close(false);
                a_strErr = e.Message;
                return(-1);
            }

            return(intInsert);
        }
Example #3
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);
        }
Example #4
0
        public static int InsertLendAptitude(UCertificatLend Lend, ref string a_strErr)
        {
            int      intInsert = 0;
            int      intupdate = 0;
            SQLTrans sqlTrans  = new SQLTrans();

            sqlTrans.Open("SupplyCnn");

            string strInsert = GSqlSentence.GetInsertInfoByD <UCertificatLend>(Lend, "tk_UCertificatLend");
            string strUpdate = "update tk_UserAptitude set State = '1' where ID = '" + Lend.StrID + "'";

            try
            {
                if (strInsert != "")
                {
                    intInsert = sqlTrans.ExecuteNonQuery(strInsert, CommandType.Text, null);
                }
                if (strUpdate != "")
                {
                    intupdate = sqlTrans.ExecuteNonQuery(strUpdate, CommandType.Text, null);
                }
                sqlTrans.Close(true);
            }
            catch (SqlException e)
            {
                sqlTrans.Close(false);
                a_strErr = e.Message;
                return(-1);
            }

            return(intInsert + intupdate);
        }
Example #5
0
        public static OperationAnalysis getOperationAnalysis(int month)
        {
            string            sql = "select top(1) OId, Year, Month, Overview, BusinesAnalysi, BusinesContent, PayableAnalysi, PayableContent, Experience, Other, Unit, CreateUser, CreateTime from OperationAnalysis where year=" + DateTime.Now.ToString("yyyy") + " and Month = " + month + " and unit='" + GAccount.GetAccountInfo().UnitName + "' order by CreateTime";
            OperationAnalysis oa  = new OperationAnalysis();

            GSqlSentence.SetTValueD <OperationAnalysis>(oa, SQLBase.FillTable(sql).Rows[0]);
            return(oa);
        }
Example #6
0
        public static PayInfo GetPayInfo(string PayId)
        {
            string    sql     = "select PayId, PaymentMethod, PayMoney, hkhorzph, PayCompany, PayType, SFKP, RendingReason, Remark, PayTime, CreateTime, CreateUser, Validate from PayInfo where PayId='" + PayId + "'";
            DataTable dt      = SQLBase.FillTable(sql);
            PayInfo   payInfo = new PayInfo();

            return(GSqlSentence.SetTValueD <PayInfo>(payInfo, dt.Rows[0]));
        }
Example #7
0
        public static bool SavePayInfo(PayInfo payInfo, List <ConsumptionInfo> list, double yk, ref string err)
        {
            if (payInfo != null)
            {
                string paySql = GSqlSentence.GetInsertInfoByD <PayInfo>(payInfo, "PayInfo");
                if (SQLBase.ExecuteNonQuery(paySql) <= 0)
                {
                    err = "缴费信息添加失败";
                    return(false);
                }
                if (!UpdatePayId(payInfo.PayId))
                {
                    err = "缴费单号更新失败";
                    return(false);
                }
            }
            string conSql = GSqlSentence.GetInsertByList <ConsumptionInfo>(list, "ConsumptionInfo");

            if (SQLBase.ExecuteNonQuery(conSql) <= 0)
            {
                err = "消费信息添加失败";
                return(false);
            }
            if (yk > 0)
            {
                string sql = "update ClientPayInfo set Money = Money-" + yk + " where ClienName ='" + payInfo.PayCompany + "'";
                if (SQLBase.ExecuteNonQuery(sql) <= 0)
                {
                    err = "更新余额失败";
                    return(false);
                }
            }
            string YYCode  = "";
            string Content = "";

            for (int i = 0; i < list.Count; i++)
            {
                YYCode  += list[i].YYCode + ",";
                Content += "缴费,缴费状态为" + list[i].Type + ",";
            }
            if (!insertLog(YYCode.Substring(0, YYCode.Length - 1), Content.Substring(0, Content.Length - 1)))
            {
                err = "更新日志失败";
                return(false);
            }
            return(true);
        }
Example #8
0
        public static tk_Product_Plan IndexAllupdatePlan(string JHID)
        {
            string    str = "select  JHID, UnitID, Plannedyear, Plannedmonth, convert(varchar(100),Specifieddate,23) Specifieddate, Formulation, Remarks, State, Approvalstatus, CreateUser, CreateTime, Validate from BGOI_Produce.dbo.tk_Product_Plan where JHID='" + JHID + "'";
            DataTable dt  = SQLBase.FillTable(str, "MainProduce");

            if (dt == null)
            {
                return(null);
            }
            tk_Product_Plan Task = new tk_Product_Plan();

            GSqlSentence.SetTValueD <tk_Product_Plan>(Task, dt.Rows[0]);
            //foreach (DataRow item in dt.Rows)
            //{
            //    DataRowToPlan(item, Task);
            //}
            return(Task);
        }
Example #9
0
        public static bool SaveProductPlan(tk_Product_Plan record, List <tk_Product_PlanDetail> delist, ref string strErr)
        {
            int count = 0;

            try
            {
                string strInsert = GSqlSentence.GetInsertInfoByD <tk_Product_Plan>(record, "[BGOI_Produce].[dbo].tk_Product_Plan");
                if (strInsert != "")
                {
                    count = SQLBase.ExecuteNonQuery(strInsert, "MainProduce");
                }
                if (count <= 0)
                {
                    strErr = "计划单保存失败!";
                    return(false);
                }

                string strInsertList = "";
                if (delist.Count > 0)
                {
                    strInsertList = GSqlSentence.GetInsertByList <tk_Product_PlanDetail>(delist, "tk_Product_PlanDetail");
                    if (strInsertList != "")
                    {
                        count = SQLBase.ExecuteNonQuery(strInsertList, "MainProduce");
                    }
                }

                if (count > 0)
                {
                    return(true);
                }

                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                strErr = ex.Message;

                return(false);
            }
        }
Example #10
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);
        }
Example #11
0
        public static bool insertLog(string YYCode, string content)
        {
            tk_Log        log  = null;
            List <tk_Log> list = new List <tk_Log>();

            string[] YYCodes  = YYCode.Split(',');
            string[] Contents = content.Split(',');
            for (int i = 0; i < YYCodes.Length; i++)
            {
                log = new tk_Log()
                {
                    ID      = Convert.ToDecimal(DateTime.Now.ToString("yyyyMMddHHmmss")),
                    LogTime = DateTime.Now,
                    YYCode  = YYCodes[i],
                    Content = Contents[i],
                    Actor   = GAccount.GetAccountInfo().UserName,
                    Unit    = GAccount.GetAccountInfo().UnitName
                };
                list.Add(log);
            }
            string logSql = GSqlSentence.GetInsertByList <tk_Log>(list, "tk_Log");

            return(SQLBase.ExecuteNonQuery(logSql) > 0);
        }
Example #12
0
        public static bool SaveOperationAnalysis(OperationAnalysis oa, List <OperationTask> list, ref string err)
        {
            string sql = GSqlSentence.GetInsertInfo <OperationAnalysis>(oa);

            if (SQLBase.ExecuteNonQuery(sql) > 0)
            {
                sql = GSqlSentence.GetInsertByList <OperationTask>(list, "OperationTask");
                if (SQLBase.ExecuteNonQuery(sql) > 0)
                {
                    if (UpdateOId(oa.OId))
                    {
                        return(true);
                    }
                    err = "编号更新失败";
                    return(false);
                }
                err = "任务信息保存失败";
                return(false);
            }


            err = "保存失败";
            return(false);
        }
Example #13
0
        public static int InsertDCheckInfo(DCheckInfo CheckInfo, ref string a_strErr)
        {
            int      intInsert = 0;
            int      intUpdate = 0;
            SQLTrans sqlTrans  = new SQLTrans();

            sqlTrans.Open("SupplyCnn");
            string   strInsert = GSqlSentence.GetInsertInfoByD <DCheckInfo>(CheckInfo, "tk_DCheckInfo");
            string   strUpdate = "";
            DateTime CheckDate = Convert.ToDateTime(CheckInfo.StrCheckDate);
            DateTime PlanDate  = new DateTime();
            string   strSql    = "";

            strSql = "select CycleType,Cycle from tk_DevicsBas where ECode = '" + CheckInfo.StrECode + "'";
            DataTable dt        = SQLBase.FillTable(strSql, "SupplyCnn");
            string    CycelType = dt.Rows[0]["CycleType"].ToString();
            int       Cycel     = Convert.ToInt16(dt.Rows[0]["Cycle"]);

            if (CycelType == "Cy1")
            {
                PlanDate = CheckDate.AddYears(Cycel);
            }
            if (CycelType == "Cy2")
            {
                PlanDate = CheckDate.AddMonths(Cycel);
            }
            if (CycelType == "Cy3")
            {
                PlanDate = CheckDate.AddDays(Cycel);
            }
            if (CheckInfo.StrPrecision != null)
            {
                strUpdate = "update tk_DevicsBas set LastDate = '" + CheckInfo.StrCheckDate + "',PlanDate = '" + PlanDate.ToString("yyyy-MM-dd") + "',Precision = '" + CheckInfo.StrPrecision + "' where ECode = '" + CheckInfo.StrECode + "'";
            }
            else
            {
                strUpdate = "update tk_DevicsBas set LastDate = '" + CheckInfo.StrCheckDate + "',PlanDate = '" + PlanDate.ToString("yyyy-MM-dd") + "' where ECode = '" + CheckInfo.StrECode + "'";
            }



            try
            {
                if (strInsert != "")
                {
                    intInsert = sqlTrans.ExecuteNonQuery(strInsert, CommandType.Text, null);
                }
                if (strUpdate != "")
                {
                    intUpdate = sqlTrans.ExecuteNonQuery(strUpdate, CommandType.Text, null);
                }
                sqlTrans.Close(true);
            }
            catch (SqlException e)
            {
                sqlTrans.Close(false);
                a_strErr = e.Message;
                return(-1);
            }

            return(intInsert + intUpdate);
        }
Example #14
0
        public static bool SaveUpdatePlan(tk_Product_Plan record, List <tk_Product_PlanDetail> delist, ref string strErr)
        {
            //SqlTransaction sqltra = con.BeginTransaction();//开始事务

            try
            {
                string         strUpdate = "update BGOI_Produce.dbo.tk_Product_Plan set Specifieddate=@Specifieddate,Plannedmonth=@Plannedmonth," + "Remarks=@Remarks,Formulation=@Formulation where JHID=@JHID";
                SqlParameter[] param     =
                {
                    new SqlParameter("@Specifieddate", SqlDbType.DateTime),
                    new SqlParameter("@Plannedmonth",  SqlDbType.NVarChar),
                    new SqlParameter("@Remarks",       SqlDbType.NVarChar),
                    new SqlParameter("@Formulation",   SqlDbType.NVarChar),
                    new SqlParameter("@JHID",          SqlDbType.NVarChar)
                };
                param[0].Value = Convert.ToDateTime(record.Specifieddate);
                param[1].Value = record.Plannedmonth;
                param[2].Value = record.Remarks == null ? "" : record.Remarks;
                param[3].Value = record.Formulation;
                param[4].Value = record.JHID;


                string InserNewOrdersHIS = "insert into BGOI_Produce.dbo.tk_Product_Plan_HIS (JHID,UnitID,Plannedyear,Plannedmonth,Specifieddate,Formulation,Remarks,State,Approvalstatus,CreateUser,CreateTime,Validate,NCreateTime,NCreateUser)" +
                                           "select JHID,UnitID,Plannedyear,Plannedmonth,Specifieddate,Formulation,Remarks,State,Approvalstatus,CreateUser,CreateTime,Validate,'" + DateTime.Now + "','" + GAccount.GetAccountInfo().UserName + "' from BGOI_Produce.dbo.tk_Product_Plan where JHID ='" + record.JHID + "'";

                int count = 0;

                count = SQLBase.ExecuteNonQuery(InserNewOrdersHIS, "MainProduce");
                if (count <= 0)
                {
                    strErr = "历史记录更新失败";
                    return(false);
                }
                count = SQLBase.ExecuteNonQuery(strUpdate, param, "MainProduce");
                if (count <= 0)
                {
                    strErr = "计划信息更新失败";
                    return(false);
                }



                string strInsertDetailHIS = "insert into BGOI_Produce.dbo.tk_Product_PlanDetail_HIS(JHID,DID,PID,Name,Specifications,Finishedproduct,finishingproduct,Spareparts,notavailable,Total,plannumber,demandnumber,Remarks,CreateUser,CreateTime,Validate,NCreateUser,NCreateTime) select JHID,DID,PID,Name,Specifications,Finishedproduct,finishingproduct,Spareparts,notavailable,Total,plannumber,demandnumber,Remarks,CreateUser,CreateTime,Validate,'" + GAccount.GetAccountInfo().UserName + "','" + DateTime.Now + "'" +
                                            " from BGOI_Produce.dbo.tk_Product_PlanDetail where JHID='" + record.JHID + "'";
                count = SQLBase.ExecuteNonQuery(strInsertDetailHIS, "MainProduce");
                if (count < 0)
                {
                    strErr = "历史记录更新失败";
                    return(false);
                }
                string strDeleteDetail = "delete tk_Product_PlanDetail where JHID='" + record.JHID + "'";
                count = SQLBase.ExecuteNonQuery(strDeleteDetail, "MainProduce");
                if (count < 0)
                {
                    return(false);
                }

                if (delist.Count > 0)
                {
                    string strUpdateList = GSqlSentence.GetInsertByList <tk_Product_PlanDetail>(delist, "tk_Product_PlanDetail");
                    count = SQLBase.ExecuteNonQuery(strUpdateList, "MainProduce");
                    if (count <= 0)
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                strErr = ex.Message;
                //trans.Close(true);
                return(false);
            }
        }
Example #15
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);
        }