Example #1
0
        public com.jwsoft.pm.entpm.model.SpoilageMain GetModel(int SpoilageID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select   ");
            builder.Append(" SpoilageID,DepositoryID,SpoilageNumber,SpoilageDate,TransactPerson,SpoilageMoney,Remark,TransactState,AuditState,UserCode,RecordDate ");
            builder.Append(" from pm_Repe_SpoilageMain ");
            builder.Append(" where SpoilageID=" + SpoilageID + " ");
            com.jwsoft.pm.entpm.model.SpoilageMain main = new com.jwsoft.pm.entpm.model.SpoilageMain();
            DataSet set = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["SpoilageID"].ToString() != "")
            {
                main.SpoilageID = int.Parse(set.Tables[0].Rows[0]["SpoilageID"].ToString());
            }
            if (set.Tables[0].Rows[0]["DepositoryID"].ToString() != "")
            {
                main.DepositoryID = int.Parse(set.Tables[0].Rows[0]["DepositoryID"].ToString());
            }
            main.SpoilageNumber = set.Tables[0].Rows[0]["SpoilageNumber"].ToString();
            if (set.Tables[0].Rows[0]["SpoilageDate"].ToString() != "")
            {
                main.SpoilageDate = DateTime.Parse(set.Tables[0].Rows[0]["SpoilageDate"].ToString());
            }
            main.TransactPerson = set.Tables[0].Rows[0]["TransactPerson"].ToString();
            if (set.Tables[0].Rows[0]["SpoilageMoney"].ToString() != "")
            {
                main.SpoilageMoney = decimal.Parse(set.Tables[0].Rows[0]["SpoilageMoney"].ToString());
            }
            main.Remark        = set.Tables[0].Rows[0]["Remark"].ToString();
            main.TransactState = set.Tables[0].Rows[0]["TransactState"].ToString();
            if (set.Tables[0].Rows[0]["AuditState"].ToString() != "")
            {
                main.AuditState = int.Parse(set.Tables[0].Rows[0]["AuditState"].ToString());
            }
            main.UserCode = set.Tables[0].Rows[0]["UserCode"].ToString();
            if (set.Tables[0].Rows[0]["RecordDate"].ToString() != "")
            {
                main.RecordDate = DateTime.Parse(set.Tables[0].Rows[0]["RecordDate"].ToString());
            }
            return(main);
        }
Example #2
0
        public bool Update(com.jwsoft.pm.entpm.model.SpoilageMain model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update pm_Repe_SpoilageMain set ");
            builder.Append("DepositoryID=" + model.DepositoryID + ",");
            builder.Append("SpoilageNumber='" + model.SpoilageNumber + "',");
            builder.Append("SpoilageDate='" + model.SpoilageDate + "',");
            builder.Append("TransactPerson='" + model.TransactPerson + "',");
            builder.Append("SpoilageMoney=" + model.SpoilageMoney + ",");
            builder.Append("Remark='" + model.Remark + "',");
            builder.Append("TransactState='" + model.TransactState + "',");
            builder.Append("UserCode='" + model.UserCode + "',");
            builder.Append("RecordDate='" + model.RecordDate + "'");
            builder.Append(" where SpoilageID=" + model.SpoilageID + " ");
            return(publicDbOpClass.NonQuerySqlString(builder.ToString()));
        }
Example #3
0
        public bool UpdateIsConfirm(int SpoilageID)
        {
            com.jwsoft.pm.entpm.model.SpoilageMain model = this.GetModel(SpoilageID);
            StringBuilder builder  = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();

            builder.Append(" select * from pm_Repe_SpoilageDetail where SpoilageID=" + model.SpoilageID + " ");
            DataTable table = publicDbOpClass.DataTableQuary(builder.ToString());

            if (table.Rows.Count > 0)
            {
                builder2.Append(" declare @num decimal(10,2) set @num=0.00 ");
                builder2.Append(" declare @Scalar decimal(10,2) set @Scalar=0.00 ");
                foreach (DataRow row in table.Rows)
                {
                    builder2.Append(string.Concat(new object[] { " if exists(select top 1 RecordID from pm_Repe_RealTime where DepositoryID= ", model.DepositoryID, " and MaterialId = ", row["MaterialId"].ToString(), " ) " }));
                    builder2.Append(" begin ");
                    builder2.Append(string.Concat(new object[] { " select @num=isnull(Amount,0) from pm_Repe_RealTime where DepositoryID= ", model.DepositoryID, " and MaterialId = ", row["MaterialId"].ToString() }));
                    builder2.Append(" select @Scalar=isnull('" + row["Scalar"].ToString() + "',0)");
                    builder2.Append(" select @num=@num-@Scalar ");
                    builder2.Append(" update pm_Repe_RealTime set ");
                    builder2.Append(" Amount=@num");
                    builder2.Append(" where ");
                    builder2.Append(" DepositoryID=" + model.DepositoryID);
                    builder2.Append(" and MaterialId = " + row["MaterialId"].ToString() + " ");
                    builder2.Append(" end ");
                    builder2.Append(" else ");
                    builder2.Append(" begin ");
                    builder2.Append(" insert into pm_Repe_RealTime(");
                    builder2.Append(" DepositoryID,MaterialId,Amount");
                    builder2.Append(" )");
                    builder2.Append(" values (");
                    builder2.Append(" " + model.DepositoryID + ",");
                    builder2.Append(" " + row["MaterialId"].ToString() + ",");
                    builder2.Append(" -" + row["Scalar"].ToString() + " ");
                    builder2.Append(" )");
                    builder2.Append(" end ");
                }
                if (publicDbOpClass.NonQuerySqlString(builder2.ToString()))
                {
                    model.TransactState = "1";
                    return(this.Update(model));
                }
            }
            return(false);
        }
Example #4
0
        public bool Add(com.jwsoft.pm.entpm.model.SpoilageMain model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into pm_Repe_SpoilageMain(");
            builder.Append("DepositoryID,SpoilageNumber,SpoilageDate,TransactPerson,SpoilageMoney,Remark,TransactState,UserCode,RecordDate");
            builder.Append(")");
            builder.Append(" values (");
            builder.Append(model.DepositoryID + ",");
            builder.Append("'" + model.SpoilageNumber + "',");
            builder.Append("'" + model.SpoilageDate + "',");
            builder.Append("'" + model.TransactPerson + "',");
            builder.Append(model.SpoilageMoney + ",");
            builder.Append("'" + model.Remark + "',");
            builder.Append("'" + model.TransactState + "',");
            builder.Append("'" + model.UserCode + "',");
            builder.Append("'" + model.RecordDate + "'");
            builder.Append(")");
            return(publicDbOpClass.NonQuerySqlString(builder.ToString()));
        }