Ejemplo n.º 1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddSQL(MaterialMRPPlan MaterialMRPPlan)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into MaterialMRPPlan(");
            strSql.Append("MaterialMRPPlanGuid,MaterialMRPPlanID,MaterialMRPPlanDate,Remark,CreateGuid,CreateDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + MaterialMRPPlan.MaterialMRPPlanGuid + "',");
            strSql.Append("'" + MaterialMRPPlan.MaterialMRPPlanID + "',");
            if (MaterialMRPPlan.MaterialMRPPlanDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null,");
            }
            else
            {
                strSql.Append("'" + MaterialMRPPlan.MaterialMRPPlanDate + "',");
            }
            strSql.Append("'" + MaterialMRPPlan.Remark + "',");
            strSql.Append("'" + MaterialMRPPlan.CreateGuid + "',");

            if (MaterialMRPPlan.CreateDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null,");
            }
            else
            {
                strSql.Append("'" + MaterialMRPPlan.CreateDate + "'");
            }

            strSql.Append(")");
            return(strSql.ToString());
        }
Ejemplo n.º 2
0
        ///<summary>
        /// 保存数据----点击保存时用
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(MaterialMRPPlan materialMRPPlan, List <MaterialMRPPlanDetail> materialMRPPlanDetail, List <MaterialMRPPlanCalcSumDetail> materialMRPPlanCalcSumDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

                //保存单据主表数据
                //先删除主表数据
                string strDeleteSql = "Delete from MaterialMRPPlan where  MaterialMRPPlanGuid='" + materialMRPPlan.MaterialMRPPlanGuid + "'";
                pComm.Execute(strDeleteSql);

                //插入主表数据
                string strInsertSql = GetAddSQL(materialMRPPlan);
                pComm.Execute(strInsertSql);


                //删除明细表
                strDeleteSql = "Delete from MaterialMRPPlanDetail where  MaterialMRPPlanGuid='" + materialMRPPlan.MaterialMRPPlanGuid + "'";
                pComm.Execute(strDeleteSql);

                //插入明细表数据
                for (int i = 0; i < materialMRPPlanDetail.Count; i++)
                {
                    strInsertSql = GetAddDetailSQL(materialMRPPlanDetail[i]);
                    pComm.Execute(strInsertSql);
                }


                //删除计算明细
                strDeleteSql = "Delete from MaterialMRPPlanCalcSum where  MaterialMRPPlanGuid='" + materialMRPPlan.MaterialMRPPlanGuid + "'";
                pComm.Execute(strDeleteSql);

                //插入明细表数据
                for (int i = 0; i < materialMRPPlanCalcSumDetail.Count; i++)
                {
                    strInsertSql = GetAddCalcSumSQL(materialMRPPlanCalcSumDetail[i]);
                    pComm.Execute(strInsertSql);
                }


                pComm.CommitTrans();
            }
            catch (Exception e)
            {
                pComm.RollbackTrans();
                pComm.Close();
                throw e;
            }
        }