Example #1
0
        private TB_DZmanuscript GetManuscript_By_SonoAnd_EntryID(string sono, int entryid, System.Data.OracleClient.OracleCommand cmd)
        {
            TB_DZmanuscript model = new TB_DZmanuscript()
            {
                Fjde_sono = sono, FsoentryID = entryid
            };

            string sql = DbUtils.GetSqlWithObject(model, Operate.Select);

            sql            += "WHERE Fjde_sono=:Fjde_sono AND FsoentryID=:FsoentryID";
            cmd.CommandText = sql;
            DbUtils.GetParams(model, cmd);

            System.Data.OracleClient.OracleDataAdapter da = new System.Data.OracleClient.OracleDataAdapter(cmd);

            System.Data.DataTable table = new System.Data.DataTable();
            da.Fill(table);

            if (table.Rows.Count == 1)
            {
                var t   = model.GetType();
                var pis = t.GetProperties().ToList();
                var row = table.Rows[0];

                model.FID = row["FID"].ToString();

                return(model);
            }

            if (table.Rows.Count > 1)
            {
                throw new Exception(string.Format("{2}表中存在多条符合条件【Fjde_sono={0} AND FsoentryID={1}】的记录", sono, entryid, table.TableName));
            }

            throw new Exception("未找到相关的底表记录");
        }
Example #2
0
        public DataResult Forder_confirm(Forder_confirm_Input input)
        {
            string sql = "";

            string where = " WHERE Fjde_sono=:Fjde_sono AND FsoentryID=:FsoentryID";
            DataResult result = new DataResult()
            {
                errCode = 0
            };

            try
            {
                DataChecker.CheckObj(input);


                TB_DZmanuscript model = new TB_DZmanuscript();

                model.Fjde_sono    = input.Fjde_sono;
                model.Fsrcbillno   = input.Fsrcbillno;
                model.Fproductcode = input.Fproductcode;
                //model.forderunit = input.Forderunit;
                model.Forderamount = input.Forderamount;
                model.FsoentryID   = input.FsoentryID;
                model.Forderprice  = input.Forderprice;
                model.Fisrejected  = input.Fisrejected;


                var cmd = DbUtils.GetCommand(model, Operate.Select);

                cmd.Parameters.AddWithValue("Fjde_sono", model.Fjde_sono);
                cmd.Parameters.AddWithValue("FsoentryID", model.FsoentryID);
                sql             = "SELECT COUNT(*) FROM TB_DZmanuscript" + where;
                cmd.CommandText = sql;
                var count = Convert.ToInt32(cmd.ExecuteScalar());

                if (count == -1)
                {
                    throw new Exception(string.Format("【{0}】销售订单号,行号【{1}】的记录不存在", input.Fjde_sono, input.FsoentryID));
                }

                sql = DbUtils.GetSqlWithObject(model, Operate.Update);

                DbUtils.GetParams(model, cmd);
                sql            += where;
                cmd.CommandText = sql;
                count           = cmd.ExecuteNonQuery();
                if (count > 0)
                {
                    cmd.Transaction.Commit();
                    cmd.Connection.Close();
                    return(result);
                }
                else
                {
                    throw new Exception("更新记录为0,未找到相关记录");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                LogHelper.WriteLog("Input: " + JsonHelper.ToJson(input));
                result.errMsg  = ex.Message;
                result.errCode = -1;
                return(result);
            }
        }