예제 #1
0
 public static void DataRowToPlan(DataRow item, tk_Product_Plan task)
 {
     task.Specifieddate = Convert.ToDateTime(item["Specifieddate"]);
     task.Plannedmonth  = item["Plannedmonth"].ToString();
     task.Remarks       = item["Remarks"].ToString();
     task.Formulation   = item["Formulation"].ToString();
 }
예제 #2
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);
        }
예제 #3
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);
            }
        }
예제 #4
0
 public static bool SaveUpdatePlan(tk_Product_Plan record, List <tk_Product_PlanDetail> delist, ref string strErr)
 {
     return(ProducePlanPro.SaveUpdatePlan(record, delist, ref strErr));
 }
예제 #5
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);
            }
        }