Exemple #1
0
        public static void Delete(EpTransaction epTran, PurchaseOrderItem entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderItem checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.PurchaseItemSequenceNumber);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update
            cm.CommandText = "DELETE FROM PURDTL WHERE EBELN=@EBELN AND EBELP=@EBELP";
            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p1);
            p1.Value = entity.OrderNumber;
            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);

            cm.Parameters.Add(p2);
            p2.Value = entity.PurchaseItemSequenceNumber;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        public static void Delete(EpTransaction epTran, PurchaseOrderHeaderText entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderHeaderText checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.TextSerialNumber);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update
            cm.CommandText = "DELETE FROM puhtxt WHERE EBELN=@EBELN AND TXTITM=@TXTITM";
            SqlParameter p3 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p3);
            p3.Value = entity.OrderNumber;
            SqlParameter p4 = new SqlParameter("@TXTITM", SqlDbType.Char, 5);

            cm.Parameters.Add(p4);
            p4.Value = entity.TextSerialNumber;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        public static Supplier RetrieveByKey(EpTransaction epTran, string supplierID)
        {
            Supplier entity = null;
            string whereClause = " LIFNR='" + DataManager.EscapeSQL(supplierID) + "' ";
            
            Collection<Supplier> entities = Retrieve(epTran, whereClause, "");
            if (entities.Count > 0)
                entity = entities[0];

            return entity;
        }
        public static PurchaseOrderHeader RetrieveByKey(EpTransaction epTran, string orderNumber)
        {
            PurchaseOrderHeader entity = null;
            string whereClause = " EBELN='" + DataManager.EscapeSQL(orderNumber) + "' ";

            Collection<PurchaseOrderHeader> entities = Retrieve(epTran, whereClause, "");
            if (entities.Count > 0)
                entity = entities[0];

            return entity;
        }
Exemple #5
0
        public static void Delete(EpTransaction epTran, Supplier entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            Supplier checkEntity = RetrieveByKey(epTran, entity.SupplierID);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update
            cm.CommandText = "DELETE FROM vndmst WHERE LIFNR=@LIFNR";
            SqlParameter p1 = new SqlParameter("@LIFNR", SqlDbType.Char, 10);

            cm.Parameters.Add(p1);
            p1.Value = entity.SupplierID;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        public static ContractItem RetrieveByKey(EpTransaction epTran, string contractNumber, string contractItemSequence)
        {
            ContractItem entity = null;
            string whereClause = " EBELN='" + DataManager.EscapeSQL(contractNumber) + "' ";
            whereClause += "AND EBELP='" + DataManager.EscapeSQL(contractItemSequence) + "'";

            Collection<ContractItem> entities = Retrieve(epTran, whereClause, "");
            if (entities.Count > 0)
                entity = entities[0];

            return entity;
        }
        public static PurchaseOrderItem RetrieveByKey(EpTransaction epTran, string orderNumber, string SequenceNO)
        {
            PurchaseOrderItem entity = null;
            string whereClause = " EBELN='" + DataManager.EscapeSQL(orderNumber) + "' ";
            whereClause += "AND EBELP='" + DataManager.EscapeSQL(SequenceNO) + "'";
            
            Collection<PurchaseOrderItem> entities = Retrieve(epTran, whereClause, "");
            if (entities.Count > 0)
                entity = entities[0];

            return entity;
        }
        public static PurchaseOrderServiceTask RetrieveByKey(EpTransaction epTran, string ServiceLineNumber, string ServiceLineSequence)
        {
            PurchaseOrderServiceTask entity =null;
            string whereClause = " LBLN1='" + DataManager.EscapeSQL(ServiceLineNumber) + "' ";
            whereClause += "AND EXTROW='" + DataManager.EscapeSQL(ServiceLineSequence) + "'";

            Collection<PurchaseOrderServiceTask> entities = Retrieve(epTran, whereClause, "");
            if (entities.Count > 0)
                entity = entities[0];

            return entity;
        }
        public static PurchaseOrderSubcontractComponent RetrieveByKey(EpTransaction epTran, string orderNumber, string ItemSequenceNumber, string ComponentSequenceNumber)
        {
            PurchaseOrderSubcontractComponent entity = null;
            string whereClause = " EBELN='" + DataManager.EscapeSQL(orderNumber) + "' ";
            whereClause += "AND EBELP='" + DataManager.EscapeSQL(ItemSequenceNumber) + "' ";
            whereClause += "AND COMPL='" + DataManager.EscapeSQL(ComponentSequenceNumber) + "'";

            Collection<PurchaseOrderSubcontractComponent> entities = Retrieve(epTran, whereClause, "");
            if (entities.Count > 0)
                entity = entities[0];

            return entity;
        }
        public static PurchaseOrderHeader RetrieveByKey(EpTransaction epTran, string orderNumber)
        {
            PurchaseOrderHeader entity = null;
            string whereClause         = " EBELN='" + DataManager.EscapeSQL(orderNumber) + "' ";

            Collection <PurchaseOrderHeader> entities = Retrieve(epTran, whereClause, "");

            if (entities.Count > 0)
            {
                entity = entities[0];
            }

            return(entity);
        }
Exemple #11
0
        public static Supplier RetrieveByKey(EpTransaction epTran, string supplierID)
        {
            Supplier entity      = null;
            string   whereClause = " LIFNR='" + DataManager.EscapeSQL(supplierID) + "' ";

            Collection <Supplier> entities = Retrieve(epTran, whereClause, "");

            if (entities.Count > 0)
            {
                entity = entities[0];
            }

            return(entity);
        }
Exemple #12
0
        public static ContractItem RetrieveByKey(EpTransaction epTran, string contractNumber, string contractItemSequence)
        {
            ContractItem entity      = null;
            string       whereClause = " EBELN='" + DataManager.EscapeSQL(contractNumber) + "' ";

            whereClause += "AND EBELP='" + DataManager.EscapeSQL(contractItemSequence) + "'";

            Collection <ContractItem> entities = Retrieve(epTran, whereClause, "");

            if (entities.Count > 0)
            {
                entity = entities[0];
            }

            return(entity);
        }
        public static PurchaseOrderServiceTask RetrieveByKey(EpTransaction epTran, string ServiceLineNumber, string ServiceLineSequence)
        {
            PurchaseOrderServiceTask entity = null;
            string whereClause = " LBLN1='" + DataManager.EscapeSQL(ServiceLineNumber) + "' ";

            whereClause += "AND EXTROW='" + DataManager.EscapeSQL(ServiceLineSequence) + "'";

            Collection <PurchaseOrderServiceTask> entities = Retrieve(epTran, whereClause, "");

            if (entities.Count > 0)
            {
                entity = entities[0];
            }

            return(entity);
        }
Exemple #14
0
        public static PurchaseOrderItem RetrieveByKey(EpTransaction epTran, string orderNumber, string SequenceNO)
        {
            PurchaseOrderItem entity      = null;
            string            whereClause = " EBELN='" + DataManager.EscapeSQL(orderNumber) + "' ";

            whereClause += "AND EBELP='" + DataManager.EscapeSQL(SequenceNO) + "'";

            Collection <PurchaseOrderItem> entities = Retrieve(epTran, whereClause, "");

            if (entities.Count > 0)
            {
                entity = entities[0];
            }

            return(entity);
        }
        public static void Insert(EpTransaction epTran, PurchaseOrderItemText entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderItemText checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.ItemSequenceNumber, entity.TextSerialNumber);
            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert 
            cm.CommandText = "INSERT INTO puitxt ([EBELN],[EBELP],[TXTITM],[LTXT],[RECSTS]) VALUES(@EBELN,@EBELP,@TXTITM,@LTXT,@RECSTS)";
            SqlParameter p1 = new SqlParameter("@LTXT", SqlDbType.NVarChar, 255);
            cm.Parameters.Add(p1);
            p1.Value = entity.LongText;
            SqlParameter p2 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);
            cm.Parameters.Add(p2);
            p2.Value = entity.RecordStatus;
            SqlParameter p3 = new SqlParameter("@EBELN", SqlDbType.Char, 10);
            cm.Parameters.Add(p3);
            p3.Value = entity.OrderNumber;
            SqlParameter p4 = new SqlParameter("@TXTITM", SqlDbType.Char, 5);
            cm.Parameters.Add(p4);
            p4.Value = entity.TextSerialNumber;
            SqlParameter p5 = new SqlParameter("@EBELP", SqlDbType.Char, 5);
            cm.Parameters.Add(p5);
            p5.Value = entity.ItemSequenceNumber;
            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
Exemple #16
0
        public static PurchaseOrderSubcontractComponent RetrieveByKey(EpTransaction epTran, string orderNumber, string ItemSequenceNumber, string ComponentSequenceNumber)
        {
            PurchaseOrderSubcontractComponent entity = null;
            string whereClause = " EBELN='" + DataManager.EscapeSQL(orderNumber) + "' ";

            whereClause += "AND EBELP='" + DataManager.EscapeSQL(ItemSequenceNumber) + "' ";
            whereClause += "AND COMPL='" + DataManager.EscapeSQL(ComponentSequenceNumber) + "'";

            Collection <PurchaseOrderSubcontractComponent> entities = Retrieve(epTran, whereClause, "");

            if (entities.Count > 0)
            {
                entity = entities[0];
            }

            return(entity);
        }
        public static void Insert(EpTransaction epTran, PurchaseOrderServiceTask entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderServiceTask checkEntity = RetrieveByKey(epTran, entity.ServiceLineNumber, entity.ServiceLineSequence);
            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert 
            cm.CommandText = "INSERT INTO PURSRH ([LBLN1],[EXTROW],[SRVPOS],[MENGE], [MEINS], [SBRTWR], [KTEXT1]) VALUES(@LBLN1,@EXTROW, @SRVPOS, @MENGE, @MEINS, @SBRTWR, @KTEXT1)";

            SqlParameter p1 = new SqlParameter("@LBLN1", SqlDbType.Char, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.ServiceLineNumber;
            SqlParameter p2 = new SqlParameter("@EXTROW", SqlDbType.Char, 10);
            cm.Parameters.Add(p2);
            p2.Value = entity.ServiceLineSequence;
            SqlParameter p3 = new SqlParameter("@SRVPOS", SqlDbType.Char, 18);
            cm.Parameters.Add(p3);
            p3.Value = entity.ServiceMaterial;
            SqlParameter p4 = new SqlParameter("@MENGE", SqlDbType.Decimal,13);
            cm.Parameters.Add(p4);
            if (entity.ServiceQuantity.HasValue)
                p4.Value = entity.ServiceQuantity;
            else
                p4.Value = DBNull.Value;

            SqlParameter p5 = new SqlParameter("@MEINS", SqlDbType.Char,3);
            cm.Parameters.Add(p5);
            p5.Value = entity.UnitOfMeasure;
            SqlParameter p6 = new SqlParameter("@SBRTWR", SqlDbType.Decimal,11);
            cm.Parameters.Add(p6);
            if (entity.ServicePrice.HasValue)
                p6.Value = entity.ServicePrice;
            else
                p6.Value = DBNull.Value;

            SqlParameter p7 = new SqlParameter("@KTEXT1", SqlDbType.VarChar, 40);
            cm.Parameters.Add(p7);
            p7.Value = entity.ServiceText;
            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
 public static Collection<PurchaseOrderServiceTask> RetrieveByQuery(EpTransaction epTran, string whereClause, string sortClaues)
 {
     return Retrieve(epTran, whereClause, sortClaues);
 }
        private static Collection<PurchaseOrderServiceTask> Retrieve(EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection<PurchaseOrderServiceTask> entities = new Collection<PurchaseOrderServiceTask>();

            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Retrieve Data
            string selectCommand = "SELECT [LBLN1],[EXTROW],[SRVPOS],[MENGE],[MEINS],[SBRTWR],[KTEXT1] FROM PURSRH";
            if (!string.IsNullOrEmpty(whereClause)) selectCommand += " where " + whereClause;
            if (!string.IsNullOrEmpty(sortClaues)) selectCommand += " order by " + sortClaues;

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();
            while (rd.Read())
            {
                PurchaseOrderServiceTask entity = new PurchaseOrderServiceTask();
                entity.ServiceLineNumber = rd["LBLN1"].ToString();
                entity.ServiceLineSequence = rd["EXTROW"].ToString();
                entity.ServiceMaterial = rd["SRVPOS"].ToString();

                if (rd.IsDBNull(3))
                    entity.ServiceQuantity = null;
                else
                    entity.ServiceQuantity = Convert.ToDecimal(rd["MENGE"].ToString());
                
                entity.UnitOfMeasure= rd["MEINS"].ToString();

                if (rd.IsDBNull(5))
                    entity.ServicePrice = null;
                else
                    entity.ServicePrice = Convert.ToDecimal(rd["SBRTWR"].ToString());
                
                entity.ServiceText = rd["KTEXT1"].ToString();
                entities.Add(entity);

            }
            // close reader
            rd.Close();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();

            return entities;
        }
Exemple #20
0
        private static Collection <PurchaseOrderItemSchedule> Retrieve(
            EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection <PurchaseOrderItemSchedule> entities = new Collection <PurchaseOrderItemSchedule>();

            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Retrieve Data
            string selectCommand = "SELECT [EBELN], [EBELP], [MATNR], [ETENR], [SLFDAT], [MENGE], [EINDT], " +
                                   "       [WEMNG], [ACKDT] , [RECSTS], [PRMDT] FROM PURSCH";

            if (!string.IsNullOrEmpty(whereClause))
            {
                selectCommand += " where " + whereClause;
            }
            if (!string.IsNullOrEmpty(sortClaues))
            {
                selectCommand += " order by " + sortClaues;
            }

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();

            while (rd.Read())
            {
                PurchaseOrderItemSchedule entity = new PurchaseOrderItemSchedule();

                entity.PurchaseOrderNumber           = rd["EBELN"].ToString();
                entity.PurchaseOrderItemSequence     = rd["EBELP"].ToString();
                entity.MaterialNumber                = rd["MATNR"].ToString();
                entity.PurchaseOrderScheduleSequence = rd["ETENR"].ToString();

                if (rd.IsDBNull(4))
                {
                    entity.OrderItemScheduleDate = null;
                }
                else
                {
                    entity.OrderItemScheduleDate = Convert.ToInt64(rd["SLFDAT"]);
                }

                if (rd.IsDBNull(5))
                {
                    entity.DeliveryScheduleQuantity = null;
                }
                else
                {
                    entity.DeliveryScheduleQuantity = Convert.ToDecimal(rd["MENGE"]);
                }

                if (rd.IsDBNull(6))
                {
                    entity.DeliveryDate = null;
                }
                else
                {
                    entity.DeliveryDate = Convert.ToInt64(rd["EINDT"]);
                }

                if (rd.IsDBNull(7))
                {
                    entity.DeliveredQuantity = null;
                }
                else
                {
                    entity.DeliveredQuantity = Convert.ToDecimal(rd["WEMNG"]);
                }

                if (rd.IsDBNull(8))
                {
                    entity.AcknowledgementDate = null;
                }
                else
                {
                    entity.AcknowledgementDate = Convert.ToInt64(rd["ACKDT"]);
                }

                entity.RecordStatus = rd["RECSTS"].ToString();

                if (rd.IsDBNull(10))
                {
                    entity.ExpeditingPromiseDate = null;
                }
                else
                {
                    entity.ExpeditingPromiseDate = Convert.ToInt64(rd["PRMDT"]);
                }

                entities.Add(entity);
            }
            // close reader
            rd.Close();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }

            return(entities);
        }
Exemple #21
0
        private static Collection <PurchaseOrderItem> Retrieve(EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection <PurchaseOrderItem> entities = new Collection <PurchaseOrderItem>();

            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Retrieve Data
            string selectCommand = "SELECT [EBELN],[EBELP],[PSTYP],[MATNR],[TXZ01],[BISMT],[MENGE],[PEINH],[MEINS],[NETPR],[REMARK],[WEMNG],[TEXT80],[AUFNR],[LGORT_D],[ASFNR],[STS2],[RECSTS],[ACKSTS] FROM purdtl";

            if (!string.IsNullOrEmpty(whereClause))
            {
                selectCommand += " where " + whereClause;
            }
            if (!string.IsNullOrEmpty(sortClaues))
            {
                selectCommand += " order by " + sortClaues;
            }

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();

            while (rd.Read())
            {
                PurchaseOrderItem entity = new PurchaseOrderItem();
                entity.PurchaseOrderNumber        = rd["EBELN"].ToString();
                entity.PurchaseItemSequenceNumber = rd["EBELP"].ToString();
                entity.PurchaseOrderType          = rd["PSTYP"].ToString();
                entity.MaterialNumber             = rd["MATNR"].ToString();
                entity.ShortText         = rd["TXZ01"].ToString();
                entity.OldMaterialNumber = rd["BISMT"].ToString();

                if (rd.IsDBNull(6))
                {
                    entity.OrderQuantity = null;
                }
                else
                {
                    entity.OrderQuantity = Convert.ToDecimal(rd["MENGE"].ToString());
                }

                if (rd.IsDBNull(7))
                {
                    entity.PricePerUnit = null;
                }
                else
                {
                    entity.PricePerUnit = Convert.ToDecimal(rd["PEINH"].ToString());
                }

                entity.UnitofMeasure = rd["MEINS"].ToString();

                if (rd.IsDBNull(8))
                {
                    entity.NetPrice = null;
                }
                else
                {
                    entity.NetPrice = Convert.ToDecimal(rd["NETPR"].ToString());
                }

                entity.Remarks = rd["REMARK"].ToString();

                if (rd.IsDBNull(9))
                {
                    entity.DeliveredQuantity = null;
                }
                else
                {
                    entity.DeliveredQuantity = Convert.ToDecimal(rd["WEMNG"].ToString());
                }

                entity.LongTextDescription     = rd["TEXT80"].ToString();
                entity.OrderNumber             = rd["AUFNR"].ToString();
                entity.StorageLocation         = rd["LGORT_D"].ToString();
                entity.ItemStatus              = rd["ASFNR"].ToString();
                entity.DeletionStatusIndicator = rd["STS2"].ToString();
                entity.RecordStatus            = rd["RECSTS"].ToString();
                entity.AcknowledgementStatus   = rd["ACKSTS"].ToString();

                entities.Add(entity);
            }
            // close reader
            rd.Close();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }

            return(entities);
        }
 public static Collection<PurchaseOrderHeader> RetrieveByQuery(EpTransaction epTran, string whereClause)
 {
     return Retrieve(epTran, whereClause, "");
 }
        public static void Insert(EpTransaction epTran, PurchaseOrderHeaderText entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderHeaderText checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.TextSerialNumber);

            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert
            cm.CommandText = "INSERT INTO puhtxt ([EBELN],[TXTITM],[LTXT],[RECSTS]) VALUES(@EBELN,@TXTITM,@LTXT,@RECSTS)";
            SqlParameter p1 = new SqlParameter("@LTXT", SqlDbType.NVarChar, 255);

            cm.Parameters.Add(p1);
            p1.Value = entity.LongText;
            SqlParameter p2 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p2);
            p2.Value = entity.RecordStatus;
            SqlParameter p3 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p3);
            p3.Value = entity.OrderNumber;
            SqlParameter p4 = new SqlParameter("@TXTITM", SqlDbType.Char, 5);

            cm.Parameters.Add(p4);
            p4.Value = entity.TextSerialNumber;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        private static Collection <PurchaseOrderServiceItem> Retrieve(EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection <PurchaseOrderServiceItem> entities = new Collection <PurchaseOrderServiceItem>();

            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Retrieve Data
            string selectCommand = "SELECT [EBELN],[EBELP],[LBLN1],[KTEXT1],[MENGE],[PREIS],[RECSTS] FROM PURSRV";

            if (!string.IsNullOrEmpty(whereClause))
            {
                selectCommand += " where " + whereClause;
            }
            if (!string.IsNullOrEmpty(sortClaues))
            {
                selectCommand += " order by " + sortClaues;
            }

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();

            while (rd.Read())
            {
                PurchaseOrderServiceItem entity = new PurchaseOrderServiceItem();
                entity.OrderNumber        = rd["EBELN"].ToString();
                entity.ItemSequenceNumber = rd["EBELP"].ToString();
                entity.ServiceLineNumber  = rd["LBLN1"].ToString();
                entity.ServiceDescription = rd["KTEXT1"].ToString();

                if (rd.IsDBNull(4))
                {
                    entity.ServiceQuantity = null;
                }
                else
                {
                    entity.ServiceQuantity = Convert.ToDecimal(rd["MENGE"].ToString());
                }

                if (rd.IsDBNull(5))
                {
                    entity.ServicePrice = null;
                }
                else
                {
                    entity.ServicePrice = Convert.ToDecimal(rd["PREIS"].ToString());
                }

                entity.RecordStatus = rd["RECSTS"].ToString();
                entities.Add(entity);
            }
            // close reader
            rd.Close();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }

            return(entities);
        }
        public static void Insert(EpTransaction epTran, PurchaseOrderServiceItem entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderServiceItem checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.ItemSequenceNumber, entity.ServiceLineNumber);

            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert
            cm.CommandText = "INSERT INTO PURSRV ([EBELN],[EBELP],[LBLN1],[KTEXT1], [MENGE], [PREIS], [RECSTS]) VALUES(@EBELN,@EBELP, @LBLN1, @KTEXT1, @MENGE, @PREIS, @RECSTS)";

            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p1);
            p1.Value = entity.OrderNumber;
            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);

            cm.Parameters.Add(p2);
            p2.Value = entity.ItemSequenceNumber;
            SqlParameter p3 = new SqlParameter("@LBLN1", SqlDbType.Char, 10);

            cm.Parameters.Add(p3);
            p3.Value = entity.ServiceLineNumber;
            SqlParameter p4 = new SqlParameter("@KTEXT1", SqlDbType.VarChar, 40);

            cm.Parameters.Add(p4);
            p4.Value = entity.ServiceDescription;
            SqlParameter p5 = new SqlParameter("@MENGE", SqlDbType.Decimal, 13);

            cm.Parameters.Add(p5);
            if (entity.ServiceQuantity.HasValue)
            {
                p5.Value = entity.ServiceQuantity.Value;
            }
            else
            {
                p5.Value = DBNull.Value;
            }

            SqlParameter p6 = new SqlParameter("@PREIS", SqlDbType.Decimal, 11);

            cm.Parameters.Add(p6);
            if (entity.ServicePrice.HasValue)
            {
                p6.Value = entity.ServicePrice.Value;
            }
            else
            {
                p6.Value = DBNull.Value;
            }

            SqlParameter p7 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p7);
            p7.Value = entity.RecordStatus;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
 public static Collection <PurchaseOrderServiceItem> RetrieveAll(EpTransaction epTran)
 {
     return(Retrieve(epTran, "", ""));
 }
        public static void Update(EpTransaction epTran, PurchaseOrderServiceItem entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderServiceItem checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.ItemSequenceNumber, entity.ServiceLineNumber);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update
            cm.CommandText = "UPDATE PURSRV SET KTEXT1=@LTEXT1,MENGE=@MENGE,PREIS=@PREIS,RECSTS=@RECSTS WHERE EBELN=@EBELN AND EBELP=@EBELP AND LBLN1=@LBLN1";
            SqlParameter p1 = new SqlParameter("@KTEXT1", SqlDbType.VarChar, 40);

            cm.Parameters.Add(p1);
            p1.Value = entity.ServiceDescription;
            SqlParameter p2 = new SqlParameter("@MENGE", SqlDbType.Decimal, 13);

            cm.Parameters.Add(p2);
            if (entity.ServiceQuantity.HasValue)
            {
                p6.Value = entity.ServiceQuantity.Value;
            }
            else
            {
                p6.Value = DBNull.Value;
            }

            SqlParameter p3 = new SqlParameter("@PREIS", SqlDbType.Decimal, 11);

            cm.Parameters.Add(p3);
            if (entity.ServicePrice.HasValue)
            {
                p3.Value = entity.ServicePrice.Value;
            }
            else
            {
                p3.Value = DBNull.Value;
            }

            SqlParameter p4 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p4);
            p4.Value = entity.RecordStatus;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
Exemple #28
0
        public static void Insert(EpTransaction epTran, PurchaseOrderSubcontractComponent entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderSubcontractComponent checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.ItemSequenceNumber, entity.ComponentSequenceNumber);

            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert
            cm.CommandText = "INSERT INTO PURSBC ([EBELN],[EBELP],[COMPL],[MATNR], [MAKTX], [BDMNG], [MEINS], [STS], [RECSTS]) VALUES(@EBELN,@EBELP, @COMPL, @MATNR, @MAKTX, @BDMNG, @MEINS, @STS, @RECSTS)";

            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p1);
            p1.Value = entity.OrderNumber;
            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);

            cm.Parameters.Add(p2);
            p2.Value = entity.ItemSequenceNumber;
            SqlParameter p3 = new SqlParameter("@COMPL", SqlDbType.Char, 5);

            cm.Parameters.Add(p3);
            p3.Value = entity.ComponentSequenceNumber;
            SqlParameter p4 = new SqlParameter("@MATNR", SqlDbType.Char, 18);

            cm.Parameters.Add(p4);
            p4.Value = entity.MaterialNumber;
            SqlParameter p5 = new SqlParameter("@MAKTX", SqlDbType.VarChar, 40);

            cm.Parameters.Add(p5);
            p5.Value = entity.MaterialDescription;
            SqlParameter p6 = new SqlParameter("@BDMNG", SqlDbType.Decimal);

            cm.Parameters.Add(p6);
            if (entity.ComponentQuantity.HasValue)
            {
                p6.Value = entity.ComponentQuantity;
            }
            else
            {
                p6.Value = DBNull.Value;
            }

            SqlParameter p7 = new SqlParameter("@MEINS", SqlDbType.Char, 3);

            cm.Parameters.Add(p7);
            p7.Value = entity.UnitOfMeasure;
            SqlParameter p8 = new SqlParameter("@STS", SqlDbType.Char, 1);

            cm.Parameters.Add(p8);
            p8.Value = entity.UnitOfMeasure;
            SqlParameter p9 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p9);
            p7.Value = entity.RecordStatus;
            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
Exemple #29
0
        private static Collection <PurchaseOrderSubcontractComponent> Retrieve(EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection <PurchaseOrderSubcontractComponent> entities = new Collection <PurchaseOrderSubcontractComponent>();

            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Retrieve Data
            string selectCommand = "SELECT [EBELN],[EBELP],[COMPL],[MATNR],[MAKTX],[BDMNG],[MEINS],[STS],[RECSTS] FROM PURSBC";

            if (!string.IsNullOrEmpty(whereClause))
            {
                selectCommand += " where " + whereClause;
            }
            if (!string.IsNullOrEmpty(sortClaues))
            {
                selectCommand += " order by " + sortClaues;
            }

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();

            while (rd.Read())
            {
                PurchaseOrderSubcontractComponent entity = new PurchaseOrderSubcontractComponent();
                entity.OrderNumber             = rd["EBELN"].ToString();
                entity.ItemSequenceNumber      = rd["EBELP"].ToString();
                entity.ComponentSequenceNumber = rd["COMPL"].ToString();
                entity.MaterialNumber          = rd["MATNR"].ToString();
                entity.MaterialDescription     = rd["MAKTX"].ToString();

                if (rd.IsDBNull(5))
                {
                    entity.ComponentQuantity = null;
                }
                else
                {
                    entity.ComponentQuantity = Convert.ToDecimal(rd["BDMNG"].ToString());
                }
                entity.UnitOfMeasure = rd["MEINS"].ToString();
                entity.ItemStatus    = rd["STS"].ToString();
                entity.RecordStatus  = rd["RECSTS"].ToString();
                entities.Add(entity);
            }
            // close reader
            rd.Close();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }

            return(entities);
        }
Exemple #30
0
        public static void Update(EpTransaction epTran, PurchaseOrderSubcontractComponent entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderSubcontractComponent checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.ItemSequenceNumber, entity.ComponentSequenceNumber);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update
            cm.CommandText = "UPDATE PURSBC SET MATNR=@MATNR,MAKTX=@MAKTX,BDMNG=@BDMNG,MEINS=@MEINS,STS=@STS,RECSTS=@RECSTS WHERE EBELN=@EBELN AND EBELP=@EBELP AND COMPL=@COMPL";
            SqlParameter p1 = new SqlParameter("@MATNR", SqlDbType.Char, 18);

            cm.Parameters.Add(p1);
            p1.Value = entity.MaterialNumber;
            SqlParameter p2 = new SqlParameter("@MAKTX", SqlDbType.VarChar, 40);

            cm.Parameters.Add(p2);
            p2.Value = entity.MaterialDescription;
            SqlParameter p3 = new SqlParameter("@BDMNG", SqlDbType.Decimal);

            cm.Parameters.Add(p3);
            if (entity.ComponentQuantity.HasValue)
            {
                p3.Value = entity.ComponentQuantity;
            }
            else
            {
                p3.Value = DBNull.Value;
            }

            SqlParameter p4 = new SqlParameter("@MEINS", SqlDbType.Char, 3);

            cm.Parameters.Add(p4);
            p4.Value = entity.UnitOfMeasure;
            SqlParameter p5 = new SqlParameter("@STS", SqlDbType.Char, 1);

            cm.Parameters.Add(p5);
            p5.Value = entity.ItemStatus;
            SqlParameter p6 = new SqlParameter("@MEINS", SqlDbType.Char, 1);

            cm.Parameters.Add(p6);
            p6.Value = entity.RecordStatus;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        private static Collection <PurchaseOrderHeaderText> Retrieve(EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection <PurchaseOrderHeaderText> entities = new Collection <PurchaseOrderHeaderText>();

            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Retrieve Data
            string selectCommand = "SELECT [EBELN],[TXTITM],[LTXT],[RECSTS] FROM puhtxt";

            if (!string.IsNullOrEmpty(whereClause))
            {
                selectCommand += " where " + whereClause;
            }
            if (!string.IsNullOrEmpty(sortClaues))
            {
                selectCommand += " order by " + sortClaues;
            }

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();

            while (rd.Read())
            {
                PurchaseOrderHeaderText entity = new PurchaseOrderHeaderText();
                entity.OrderNumber      = rd["EBELN"].ToString();
                entity.TextSerialNumber = rd["TXTITM"].ToString();
                entity.LongText         = rd["LTXT"].ToString();
                entity.RecordStatus     = rd["RECSTS"].ToString();
                entities.Add(entity);
            }
            // close reader
            rd.Close();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }

            return(entities);
        }
        public static void Insert(EpTransaction epTran, PurchaseOrderHeader entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderHeader checkEntity = RetrieveByKey(epTran, entity.OrderNumber);
            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert 
            cm.CommandText = "INSERT INTO purhdr ([EBELN],[LIFNR],[BEDAT],[AMTPR],[GSTPR],[WAERS],[ZTERM],[BUYER],[AD_TLNMBR],[VERKF],[ADRNR_TXT],[REMARK],[STAT],[RECSTS],[ACKSTS]) VALUES(@EBELN,@LIFNR,@BEDAT,@AMTPR,@GSTPR,@WAERS,@ZTERM,@BUYER,@AD_TLNMBR,@VERKF,@ADRNR_TXT,@REMARK,@STAT,@RECSTS,@ACKSTS)";
            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.OrderNumber;
            SqlParameter p2 = new SqlParameter("@LIFNR", SqlDbType.Char, 10);
            cm.Parameters.Add(p2);
            p2.Value = entity.SupplierID;
            SqlParameter p3 = new SqlParameter("@BEDAT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p3);
            if (entity.OrderDate.HasValue)
                p3.Value = entity.OrderDate;
            else
                p3.Value = DBNull.Value;
            SqlParameter p4 = new SqlParameter("@AMTPR", SqlDbType.Decimal, 11);
            cm.Parameters.Add(p4);
            if (entity.OrderAmount.HasValue)
                p4.Value = entity.OrderAmount;
            else
                p4.Value = DBNull.Value;
            SqlParameter p5 = new SqlParameter("@GSTPR", SqlDbType.Decimal, 11);
            cm.Parameters.Add(p5);
            if (entity.GstAmount.HasValue)
                p5.Value = entity.GstAmount;
            else
                p5.Value = DBNull.Value;
            SqlParameter p6 = new SqlParameter("@WAERS", SqlDbType.Char, 5);
            cm.Parameters.Add(p6);
            p6.Value = entity.CurrencyCode;
            SqlParameter p7 = new SqlParameter("@ZTERM", SqlDbType.Char, 4);
            cm.Parameters.Add(p7);
            p7.Value = entity.PaymentTerms;
            SqlParameter p8 = new SqlParameter("@BUYER", SqlDbType.VarChar, 31);
            cm.Parameters.Add(p8);
            p8.Value = entity.BuyerName;
            SqlParameter p9 = new SqlParameter("@AD_TLNMBR", SqlDbType.VarChar, 30);
            cm.Parameters.Add(p9);
            p9.Value = entity.AddressNumber;
            SqlParameter p10 = new SqlParameter("@VERKF", SqlDbType.VarChar, 30);
            cm.Parameters.Add(p10);
            p10.Value = entity.SalesPerson;
            SqlParameter p11 = new SqlParameter("@ADRNR_TXT", SqlDbType.VarChar, 80);
            cm.Parameters.Add(p11);
            p11.Value = entity.ShipmentAddress;
            SqlParameter p12 = new SqlParameter("@REMARK", SqlDbType.VarChar, 60);
            cm.Parameters.Add(p12);
            p12.Value = entity.Remarks;
            SqlParameter p13 = new SqlParameter("@STAT", SqlDbType.Char, 3);
            cm.Parameters.Add(p13);
            p13.Value = entity.OrderStatus;
            SqlParameter p14 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);
            cm.Parameters.Add(p14);
            p14.Value = entity.RecordStatus;
            SqlParameter p15 = new SqlParameter("@ACKSTS", SqlDbType.Char, 1);
            cm.Parameters.Add(p15);
            p15.Value = entity.AcknowledgeStatus;

            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
Exemple #33
0
 public static Collection <PurchaseOrderSubcontractComponent> RetrieveAll(EpTransaction epTran, string sortClaues)
 {
     return(Retrieve(epTran, "", sortClaues));
 }
Exemple #34
0
        public static void Insert(EpTransaction epTran, PurchaseOrderItem entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderItem checkEntity = RetrieveByKey(epTran, entity.PurchaseOrderNumber, entity.PurchaseItemSequenceNumber);

            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert
            cm.CommandText = "INSERT INTO PURDTL ([EBELN],[EBELP],[PSTYP],[MATNR],[TXZ01],[BISMT],[MENGE],[PEINH],[MEINS],[NETPR],[REMARK],[WEMNG],[TEXT80],[AUFNR],[LGORT_D],[ASFNR],[STS2],[RECSTS],[ACKSTS]) VALUES(@EBELN, @EBELP, @PSTYP, @MATNR, @TXZ01,@BISMT, @MENGE, @PEINH, @MEINS , @NETPR, @REMARK, @WEMNG, @TEXT80, @AUFNR, @LGORT_D, @ASFNR, @STS2, @RECSTS, @ACKSTS)";

            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p1);
            p1.Value = entity.PurchaseOrderNumber;

            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);

            cm.Parameters.Add(p2);
            p2.Value = entity.PurchaseItemSequenceNumber;

            SqlParameter p3 = new SqlParameter("@PSTYP", SqlDbType.Char, 1);

            cm.Parameters.Add(p3);
            p3.Value = entity.PurchaseOrderType;

            SqlParameter p4 = new SqlParameter("@MATNR", SqlDbType.Char, 18);

            cm.Parameters.Add(p4);
            p4.Value = entity.MaterialNumber;

            SqlParameter p5 = new SqlParameter("@TXZ01", SqlDbType.VarChar, 40);

            cm.Parameters.Add(p5);
            p5.Value = entity.ShortText;

            SqlParameter p6 = new SqlParameter("@BISMT", SqlDbType.Char, 18);

            cm.Parameters.Add(p6);
            p6.Value = entity.OldMaterialNumber;

            SqlParameter p7 = new SqlParameter("@MENGE", SqlDbType.Decimal, 13);

            cm.Parameters.Add(p7);
            if (entity.OrderQuantity.HasValue)
            {
                p7.Value = entity.OrderQuantity.Value;
            }
            else
            {
                p7.Value = DBNull.Value;
            }

            SqlParameter p8 = new SqlParameter("@PEINH", SqlDbType.Decimal, 13);

            cm.Parameters.Add(p8);
            if (entity.PricePerUnit.HasValue)
            {
                p8.Value = entity.PricePerUnit.Value;
            }
            else
            {
                p7.Value = DBNull.Value;
            }

            SqlParameter p9 = new SqlParameter("@MEINS", SqlDbType.Char, 3);

            cm.Parameters.Add(p9);
            p9.Value = entity.UnitofMeasure;

            SqlParameter p10 = new SqlParameter("@NETPR", SqlDbType.Decimal, 13);

            cm.Parameters.Add(p10);
            if (entity.NetPrice.HasValue)
            {
                p10.Value = entity.NetPrice.Value;
            }
            else
            {
                p10.Value = DBNull.Value;
            }

            SqlParameter p11 = new SqlParameter("@REMARK", SqlDbType.VarChar, 60);

            cm.Parameters.Add(p11);
            p11.Value = entity.Remarks;

            SqlParameter p12 = new SqlParameter("@WEMNG", SqlDbType.Decimal, 13);

            cm.Parameters.Add(p12);
            if (entity.DeliveredQuantity.HasValue)
            {
                p12.Value = entity.DeliveredQuantity.Value;
            }
            else
            {
                p12.Value = DBNull.Value;
            }

            SqlParameter p13 = new SqlParameter("@TEXT80", SqlDbType.VarChar, 80);

            cm.Parameters.Add(p13);
            p13.Value = entity.LongTextDescription;

            SqlParameter p14 = new SqlParameter("@AUFNR", SqlDbType.VarChar, 12);

            cm.Parameters.Add(p14);
            p14.Value = entity.OrderNumber;

            SqlParameter p15 = new SqlParameter("@LGORT_D", SqlDbType.Char, 4);

            cm.Parameters.Add(p15);
            p15.Value = entity.StorageLocation;

            SqlParameter p16 = new SqlParameter("@ASFNR", SqlDbType.Char, 3);

            cm.Parameters.Add(p16);
            p16.Value = entity.ItemStatus;

            SqlParameter p17 = new SqlParameter("@STS2", SqlDbType.Char, 1);

            cm.Parameters.Add(p17);
            p17.Value = entity.DeletionStatusIndicator;

            SqlParameter p18 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p18);
            p18.Value = entity.RecordStatus;

            SqlParameter p19 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p19);
            p19.Value = entity.RecordStatus;

            SqlParameter p20 = new SqlParameter("@ACKSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p20);
            p20.Value = entity.AcknowledgementStatus;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
Exemple #35
0
 public static Collection <PurchaseOrderItem> RetrieveByQuery(EpTransaction epTran, string whereClause)
 {
     return(Retrieve(epTran, whereClause, ""));
 }
        public static void Delete(EpTransaction epTran, PurchaseOrderServiceTask entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderServiceTask checkEntity = RetrieveByKey(epTran, entity.ServiceLineNumber, entity.ServiceLineSequence);
            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update 
            cm.CommandText = "DELETE FROM PURSRH WHERE LBLN1=@LBLN1 AND EXTROW=@EXTROW";
            SqlParameter p1 = new SqlParameter("@LBLN1", SqlDbType.Char, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.ServiceLineNumber;
            SqlParameter p2 = new SqlParameter("@EXTROW", SqlDbType.Char, 10);
            cm.Parameters.Add(p2);
            p2.Value = entity.ServiceLineSequence;
            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
 public static Collection<ContractItem> RetrieveAll(EpTransaction epTran)
 {
     return Retrieve(epTran, "", "");
 }
Exemple #38
0
 public static Collection <PurchaseOrderSubcontractComponent> RetrieveByQuery(EpTransaction epTran, string whereClause, string sortClaues)
 {
     return(Retrieve(epTran, whereClause, sortClaues));
 }
        public static void Update(EpTransaction epTran, PurchaseOrderServiceTask entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderServiceTask checkEntity = RetrieveByKey(epTran, entity.ServiceLineNumber, entity.ServiceLineSequence);
            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update 
            cm.CommandText = "UPDATE PURSRH SET SRVPOS=@SRVPOS,MENGE=@MENGE,MEINS=@MEINS,SBRTWR=@SBRTWR, KTEXT1=@KTEXT1 WHERE LBLN1=@LBLN1 AND EXTROW=@EXTROW";
            SqlParameter p1 = new SqlParameter("@SRVPOS", SqlDbType.Char, 18);
            cm.Parameters.Add(p1);
            p1.Value = entity.ServiceLineSequence;
            SqlParameter p2 = new SqlParameter("@MENGE", SqlDbType.Decimal);
            cm.Parameters.Add(p2);
            if (entity.ServiceQuantity.HasValue)
                p2.Value = entity.ServiceQuantity;
            else
                p2.Value = DBNull.Value;
            
            SqlParameter p3 = new SqlParameter("@MEINS", SqlDbType.Char,3);
            cm.Parameters.Add(p3);
            p3.Value = entity.UnitOfMeasure;
            SqlParameter p4 = new SqlParameter("@SBRTWR", SqlDbType.Decimal,13);
            cm.Parameters.Add(p4);
            if (entity.ServicePrice.HasValue)
                p4.Value = entity.ServicePrice;
            else
                p4.Value = DBNull.Value;

            SqlParameter p5 = new SqlParameter("@KTEXT1", SqlDbType.VarChar, 40);
            cm.Parameters.Add(p5);
            p5.Value = entity.ServiceText;
            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
 public static Collection<ContractItem> RetrieveAll(EpTransaction epTran, string sortClaues)
 {
     return Retrieve(epTran, "", sortClaues);
 }
 public static Collection<PurchaseOrderServiceTask> RetrieveAll(EpTransaction epTran)
 {
     return Retrieve(epTran, "", "");
 }
        public static void Delete(EpTransaction epTran, ContractItem entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            ContractItem checkEntity = RetrieveByKey(epTran, entity.ContractNumber, entity.ContractItemSequence);
            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update 
            cm.CommandText = "DELETE FROM contitm WHERE EBELN=@EBELN AND EBELP=@EBELP";
            
            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.VarChar, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.ContractNumber;

            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.VarChar, 5);
            cm.Parameters.Add(p2);
            p2.Value = entity.ContractItemSequence;


            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
 public static Collection<PurchaseOrderServiceTask> RetrieveAll(EpTransaction epTran, string sortClaues)
 {
     return Retrieve(epTran, "", sortClaues);
 }
        private static Collection<ContractItem> Retrieve(EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection<ContractItem> entities = new Collection<ContractItem>();

            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Retrieve Data
            string selectCommand = "SELECT [EBELN],[EBELP],[TXZ01],[MATNR],[WERKS],[MATKL],[KTMNG],[MEINS],[NETPR],[PEINH],[BRTWR],[ANFNR],[BANFN],[AFNAM] FROM contitm";
            if (!string.IsNullOrEmpty(whereClause)) selectCommand += " where " + whereClause;
            if (!string.IsNullOrEmpty(sortClaues)) selectCommand += " order by " + sortClaues;

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();
            while (rd.Read())
            {
                ContractItem entity = new ContractItem();
                entity.ContractNumber = rd["EBELN"].ToString();
                entity.ContractItemSequence = rd["EBELP"].ToString();
                entity.Description  = rd["TXZ01"].ToString();
                entity.MaterialNumber  = rd["MATNR"].ToString();
                entity.Plant = rd["WERKS"].ToString();
                entity.MaterialGroup = rd["MATKL"].ToString();

                if (rd.IsDBNull(6))
                    entity.TargetQuantity  = null;
                else
                    entity.TargetQuantity = Convert.ToInt64(rd["KTMNG"]);
                
                entity.UnitOfMeasure  = rd["MEINS"].ToString();

                if (rd.IsDBNull(8))
                    entity.UnitPrice  = null;
                else
                    entity.UnitPrice = Convert.ToInt64(rd["NETPR"]);

                if (rd.IsDBNull(9))
                    entity.PricePerUnit  = null;
                else
                    entity.PricePerUnit = Convert.ToInt64(rd["PEINH"]);

                if (rd.IsDBNull(10))
                    entity.NetValue = null;
                else
                    entity.NetValue = Convert.ToInt64(rd["BRTWR"]);

                entity.RFQNumber  = rd["ANFNR"].ToString();
                entity.RequisitionNumber  = rd["BANFN"].ToString();
                entity.Requisitioner  = rd["AFNAM"].ToString();

                entities.Add(entity);

            }
            // close reader
            rd.Close();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();

            return entities;
        }
 public static Collection<ContractItem> RetrieveByQuery(EpTransaction epTran, string whereClause, string sortClaues)
 {
     return Retrieve(epTran, whereClause, sortClaues);
 }
 public static Collection<PurchaseOrderItemSchedule> RetrieveAll(EpTransaction epTran)
 {
     return Retrieve(epTran, "", "");
 }
 public static Collection <PurchaseOrderHeaderText> RetrieveAll(EpTransaction epTran)
 {
     return(Retrieve(epTran, "", ""));
 }
        public static void Delete(EpTransaction epTran, PurchaseOrderItemSchedule entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            
            PurchaseOrderItemSchedule checkEntity = RetrieveByKey
                (epTran, entity.PurchaseOrderNumber, entity.PurchaseOrderItemSequence, entity.PurchaseOrderScheduleSequence);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update 
            cm.CommandText = "DELETE FROM PURSCH WHERE EBELN=@EBELN AND EBELP=@EBELP AND ETENR = @ETENR ";

            SqlParameter p3 = new SqlParameter("@EBELN", SqlDbType.Char, 10);
            cm.Parameters.Add(p3);
            p3.Value = entity.PurchaseOrderNumber ;

            SqlParameter p4 = new SqlParameter("@EBELP", SqlDbType.Char, 5);
            cm.Parameters.Add(p4);
            p4.Value = entity.PurchaseOrderItemSequence ;


            SqlParameter p5 = new SqlParameter("@ETENR", SqlDbType.Char, 4);
            cm.Parameters.Add(p5);
            p5.Value = entity.PurchaseOrderScheduleSequence ;

            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
 public static Collection <PurchaseOrderHeaderText> RetrieveAll(EpTransaction epTran, string sortClaues)
 {
     return(Retrieve(epTran, "", sortClaues));
 }
 public static Collection<PurchaseOrderItemSchedule> RetrieveByQuery
     (EpTransaction epTran, string whereClause, string sortClaues)
 {
     return Retrieve(epTran, whereClause, sortClaues);
 }
 public static Collection <PurchaseOrderHeaderText> RetrieveByQuery(EpTransaction epTran, string whereClause, string sortClaues)
 {
     return(Retrieve(epTran, whereClause, sortClaues));
 }
Exemple #52
0
        public static void Insert(EpTransaction epTran, PurchaseOrderItemSchedule entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderItemSchedule checkEntity = RetrieveByKey(epTran, entity.PurchaseOrderNumber, entity.PurchaseOrderItemSequence, entity.PurchaseOrderScheduleSequence);

            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert
            cm.CommandText = "INSERT INTO PURSCH ([EBELN], [EBELP], [MATNR], [ETENR], [SLFDAT], [MENGE], [EINDT], [WEMNG], [ACKDT], [RECSTS], [PRMDT]) VALUES(@EBELN, @EBELP, @MATNR, @ETENR, @SLFDAT, @MENGE, @EINDT, @WEMNG, @ACKDT, @RECSTS, @PRMDT)";

            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p1);
            p1.Value = entity.PurchaseOrderNumber;

            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);

            cm.Parameters.Add(p2);
            p2.Value = entity.PurchaseOrderScheduleSequence;

            SqlParameter p3 = new SqlParameter("@MATNR", SqlDbType.Char, 18);

            cm.Parameters.Add(p3);
            p3.Value = entity.MaterialNumber;

            SqlParameter p4 = new SqlParameter("@ETENR", SqlDbType.Char, 4);

            cm.Parameters.Add(p4);
            p4.Value = entity.PurchaseOrderScheduleSequence;

            SqlParameter p5 = new SqlParameter("@SLFDAT", SqlDbType.BigInt, 8);

            cm.Parameters.Add(p5);
            if (entity.OrderItemScheduleDate.HasValue)
            {
                p5.Value = entity.OrderItemScheduleDate.Value;
            }
            else
            {
                p5.Value = DBNull.Value;
            }

            SqlParameter p6 = new SqlParameter("@MENGE", SqlDbType.Decimal, 4);

            cm.Parameters.Add(p6);
            if (entity.DeliveryScheduleQuantity.HasValue)
            {
                p6.Value = entity.DeliveryScheduleQuantity;
            }
            else
            {
                p6.Value = DBNull.Value;
            }

            SqlParameter p7 = new SqlParameter("@EINDT", SqlDbType.BigInt, 8);

            cm.Parameters.Add(p7);
            if (entity.DeliveryDate.HasValue)
            {
                p7.Value = entity.DeliveryDate;
            }
            else
            {
                p7.Value = DBNull.Value;
            }

            SqlParameter p8 = new SqlParameter("@WEMNG", SqlDbType.Decimal, 4);

            cm.Parameters.Add(p8);
            if (entity.DeliveredQuantity.HasValue)
            {
                p8.Value = entity.DeliveredQuantity;
            }
            else
            {
                p8.Value = DBNull.Value;
            }

            SqlParameter p9 = new SqlParameter("@ACKDT", SqlDbType.BigInt, 8);

            cm.Parameters.Add(p9);
            if (entity.AcknowledgementDate.HasValue)
            {
                p9.Value = entity.AcknowledgementDate;
            }
            else
            {
                p9.Value = DBNull.Value;
            }

            SqlParameter p10 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p10);
            p10.Value = entity.RecordStatus;

            SqlParameter p11 = new SqlParameter("@PRMDT", SqlDbType.BigInt, 8);

            cm.Parameters.Add(p11);
            if (entity.ExpeditingPromiseDate.HasValue)
            {
                p11.Value = entity.ExpeditingPromiseDate;
            }
            else
            {
                p11.Value = DBNull.Value;
            }

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        public static void Update(EpTransaction epTran, PurchaseOrderItemSchedule entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderItemSchedule checkEntity = RetrieveByKey(epTran, entity.PurchaseOrderNumber, entity.PurchaseOrderItemSequence, entity.PurchaseOrderScheduleSequence);
            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update 
            cm.CommandText = "UPDATE PURSCH SET MATNR = @MATNR, SLFDAT = @SLFDAT , MENGE = @MENGE, EINDT = @EINDT , WEMNG = @WEMNG, ACKDT = @ACKDT , RECSTS = @RECSTS, PRMDT = @PRMDT WHERE EBELN=@EBELN AND EBELP=@EBELP AND ETENR = @ETENR ";
            
            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.PurchaseOrderNumber;

            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);
            cm.Parameters.Add(p2);
            p2.Value = entity.PurchaseOrderItemSequence;

            SqlParameter p3 = new SqlParameter("@MATNR", SqlDbType.Char, 18);
            cm.Parameters.Add(p3);
            p3.Value = entity.MaterialNumber;

            SqlParameter p4 = new SqlParameter("@ETENR", SqlDbType.Char, 4);
            cm.Parameters.Add(p4);
            p4.Value = entity.PurchaseOrderScheduleSequence;

            SqlParameter p5 = new SqlParameter("@SLFDAT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p5);
            if(entity.OrderItemScheduleDate.HasValue) 
                p5.Value = entity.OrderItemScheduleDate.Value;
            else
                p5.Value = DBNull.Value ;

            SqlParameter p6 = new SqlParameter("@MENGE", SqlDbType.Decimal, 4);
            cm.Parameters.Add(p6);
            if (entity.DeliveryScheduleQuantity.HasValue) 
                p6.Value = entity.DeliveryScheduleQuantity;
            else
                p6.Value = DBNull.Value;

            SqlParameter p7 = new SqlParameter("@EINDT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p7);
            if (entity.DeliveryDate.HasValue)
                p7.Value = entity.DeliveryDate;
            else
                p7.Value = DBNull.Value;

            SqlParameter p8 = new SqlParameter("@WEMNG", SqlDbType.Decimal, 4);
            cm.Parameters.Add(p8);
            if (entity.DeliveredQuantity.HasValue)
                p8.Value = entity.DeliveredQuantity;
            else
                p8.Value = DBNull.Value;

            SqlParameter p9 = new SqlParameter("@ACKDT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p9);
            if (entity.AcknowledgementDate.HasValue)
                p9.Value = entity.AcknowledgementDate;
            else
                p9.Value = DBNull.Value;

            SqlParameter p10 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);
            cm.Parameters.Add(p10);
            p10.Value = entity.RecordStatus;

            SqlParameter p11 = new SqlParameter("@PRMDT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p11);
            if (entity.ExpeditingPromiseDate.HasValue)
                p11.Value = entity.ExpeditingPromiseDate;
            else
                p11.Value = DBNull.Value;

            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
Exemple #54
0
 public static Collection <PurchaseOrderSubcontractComponent> RetrieveAll(EpTransaction epTran)
 {
     return(Retrieve(epTran, "", ""));
 }
 public static Collection<PurchaseOrderItemSchedule> RetrieveAll(EpTransaction epTran, string sortClaues)
 {
     return Retrieve(epTran, "", sortClaues);
 }
        public static void Insert(EpTransaction epTran, ContractItem entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            ContractItem checkEntity = RetrieveByKey(epTran, entity.ContractNumber, entity.ContractItemSequence);
            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert 
            cm.CommandText = "INSERT INTO contitm ([EBELN],[EBELP],[TXZ01],[MATNR],[WERKS],[MATKL],[KTMNG],[MEINS],[NETPR],[PEINH],[BRTWR],[ANFNR],[BANFN],[AFNAM]) VALUES(@EBELN,@EBELP,@TXZ01,@MATNR,@WERKS,@MATKL,@KTMNG,@MEINS,@NETPR,@PEINH,@BRTWR,@ANFNR,@BANFN,@AFNAM)";
           
            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.VarChar, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.ContractNumber;

            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.VarChar, 5);
            cm.Parameters.Add(p2);
            p2.Value = entity.ContractItemSequence;

            SqlParameter p3 = new SqlParameter("@TXZ01", SqlDbType.VarChar, 40);
            cm.Parameters.Add(p3);
            p3.Value = entity.Description;

            SqlParameter p4 = new SqlParameter("@MATNR", SqlDbType.VarChar, 18);
            cm.Parameters.Add(p4);
            p4.Value = entity.MaterialNumber;

            SqlParameter p5 = new SqlParameter("@WERKS", SqlDbType.Char, 4);
            cm.Parameters.Add(p5);
            p5.Value = entity.Plant;

            SqlParameter p6 = new SqlParameter("@MATKL", SqlDbType.VarChar, 9);
            cm.Parameters.Add(p6);
            p6.Value = entity.MaterialGroup;

            SqlParameter p7 = new SqlParameter("@KTMNG", SqlDbType.Decimal, 13);
            cm.Parameters.Add(p7);
            if (entity.TargetQuantity.HasValue)
                p7.Value = entity.TargetQuantity;
            else
                p7.Value = DBNull.Value;

            SqlParameter p8 = new SqlParameter("@MEINS", SqlDbType.Char, 3);
            cm.Parameters.Add(p8);
            p8.Value = entity.UnitOfMeasure;

            SqlParameter p9 = new SqlParameter("@NETPR", SqlDbType.Decimal, 11);
            cm.Parameters.Add(p9);
            if (entity.UnitPrice.HasValue)
                p9.Value = entity.UnitPrice;
            else
                p9.Value = DBNull.Value;

            SqlParameter p10 = new SqlParameter("@PEINH", SqlDbType.Decimal, 5);
            cm.Parameters.Add(p10);
            if (entity.PricePerUnit.HasValue)
                p10.Value = entity.PricePerUnit;
            else
                p10.Value = DBNull.Value;

            SqlParameter p11 = new SqlParameter("@BRTWR", SqlDbType.Decimal, 13);
            cm.Parameters.Add(p11);
            if (entity.NetValue.HasValue)
                p11.Value = entity.NetValue;
            else
                p11.Value = DBNull.Value;

            SqlParameter p12 = new SqlParameter("@ANFNR", SqlDbType.VarChar, 10);
            cm.Parameters.Add(p12);
            p12.Value = entity.RFQNumber;

            SqlParameter p13 = new SqlParameter("@BANFN", SqlDbType.VarChar, 10);
            cm.Parameters.Add(p13);
            p13.Value = entity.RequisitionNumber;

            SqlParameter p14 = new SqlParameter("@AFNAM", SqlDbType.VarChar, 12);
            cm.Parameters.Add(p14);
            p14.Value = entity.Requisitioner;

            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
        private static Collection<PurchaseOrderItemSchedule> Retrieve(
            EpTransaction epTran, string whereClause, string sortClaues)
        {
            Collection<PurchaseOrderItemSchedule> entities = new Collection<PurchaseOrderItemSchedule>();

            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Retrieve Data
            string selectCommand = "SELECT [EBELN], [EBELP], [MATNR], [ETENR], [SLFDAT], [MENGE], [EINDT], " + 
                                   "       [WEMNG], [ACKDT] , [RECSTS], [PRMDT] FROM PURSCH";

            if (!string.IsNullOrEmpty(whereClause)) selectCommand += " where " + whereClause;
            if (!string.IsNullOrEmpty(sortClaues)) selectCommand += " order by " + sortClaues;

            cm.CommandText = selectCommand;
            SqlDataReader rd = cm.ExecuteReader();
            while (rd.Read())
            {
                PurchaseOrderItemSchedule entity = new PurchaseOrderItemSchedule();

                entity.PurchaseOrderNumber  = rd["EBELN"].ToString();
                entity.PurchaseOrderItemSequence = rd["EBELP"].ToString();
                entity.MaterialNumber  = rd["MATNR"].ToString();
                entity.PurchaseOrderScheduleSequence = rd["ETENR"].ToString();
                
                if (rd.IsDBNull(4))
                    entity.OrderItemScheduleDate = null;
                else
                    entity.OrderItemScheduleDate  =Convert.ToInt64(rd["SLFDAT"]);

                if (rd.IsDBNull(5))
                    entity.DeliveryScheduleQuantity = null;
                else
                    entity.DeliveryScheduleQuantity = Convert.ToDecimal(rd["MENGE"]);

                if (rd.IsDBNull(6))
                    entity.DeliveryDate = null;
                else
                    entity.DeliveryDate = Convert.ToInt64(rd["EINDT"]);

                if (rd.IsDBNull(7))
                    entity.DeliveredQuantity = null;
                else
                    entity.DeliveredQuantity = Convert.ToDecimal(rd["WEMNG"]);

                if (rd.IsDBNull(8))
                    entity.AcknowledgementDate = null;
                else
                    entity.AcknowledgementDate = Convert.ToInt64(rd["ACKDT"]);

                entity.RecordStatus  = rd["RECSTS"].ToString();

                if (rd.IsDBNull(10))
                    entity.ExpeditingPromiseDate = null;
                else
                    entity.ExpeditingPromiseDate = Convert.ToInt64(rd["PRMDT"]);

                entities.Add(entity);

            }
            // close reader
            rd.Close();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();

            return entities;
        }
Exemple #58
0
        public static void Update(EpTransaction epTran, PurchaseOrderItemText entity)
        {
            SqlCommand cm = new SqlCommand();

            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;

            if (epTran == null)
            {
                connection = DataManager.GetConnection();
            }
            else
            {
                connection = epTran.GetSqlConnection();
            }
            if (connection.State != System.Data.ConnectionState.Open)
            {
                connection.Open();
            }
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
            {
                cm.Transaction = epTran.GetSqlTransaction();
            }

            //Check whether record exists
            PurchaseOrderItemText checkEntity = RetrieveByKey(epTran, entity.OrderNumber, entity.ItemSequenceNumber, entity.TextSerialNumber);

            if (checkEntity == null)
            {
                throw new Exception("Record doesn't exist.");
            }

            //Update
            cm.CommandText = "UPDATE puitxt SET LTXT=@LTXT,RECSTS=@RECSTS WHERE EBELN=@EBELN AND EBELP=@EBELP AND TXTITM=@TXTITM";
            SqlParameter p1 = new SqlParameter("@LTXT", SqlDbType.NVarChar, 255);

            cm.Parameters.Add(p1);
            p1.Value = entity.LongText;
            SqlParameter p2 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);

            cm.Parameters.Add(p2);
            p2.Value = entity.RecordStatus;
            SqlParameter p3 = new SqlParameter("@EBELN", SqlDbType.Char, 10);

            cm.Parameters.Add(p3);
            p3.Value = entity.OrderNumber;
            SqlParameter p4 = new SqlParameter("@TXTITM", SqlDbType.Char, 5);

            cm.Parameters.Add(p4);
            p4.Value = entity.TextSerialNumber;
            SqlParameter p5 = new SqlParameter("@EBELP", SqlDbType.Char, 5);

            cm.Parameters.Add(p5);
            p5.Value = entity.ItemSequenceNumber;

            cm.ExecuteNonQuery();

            if (epTran == null)
            {
                if (connection.State != System.Data.ConnectionState.Closed)
                {
                    connection.Close();
                }
            }
        }
        public static void Insert(EpTransaction epTran, PurchaseOrderItemSchedule entity)
        {
            SqlCommand cm = new SqlCommand();
            cm.CommandType = CommandType.Text;

            //set connection
            SqlConnection connection;
            if (epTran == null)
                connection = DataManager.GetConnection();
            else
                connection = epTran.GetSqlConnection();
            if (connection.State != System.Data.ConnectionState.Open) connection.Open();
            cm.Connection = connection;

            //set transaction
            if (epTran != null)
                cm.Transaction = epTran.GetSqlTransaction();

            //Check whether record exists
            PurchaseOrderItemSchedule checkEntity = RetrieveByKey(epTran, entity.PurchaseOrderNumber, entity.PurchaseOrderItemSequence, entity.PurchaseOrderScheduleSequence);
            if (checkEntity != null)
            {
                throw new Exception("Record already exists.");
            }

            //Insert 
            cm.CommandText = "INSERT INTO PURSCH ([EBELN], [EBELP], [MATNR], [ETENR], [SLFDAT], [MENGE], [EINDT], [WEMNG], [ACKDT], [RECSTS], [PRMDT]) VALUES(@EBELN, @EBELP, @MATNR, @ETENR, @SLFDAT, @MENGE, @EINDT, @WEMNG, @ACKDT, @RECSTS, @PRMDT)";

            SqlParameter p1 = new SqlParameter("@EBELN", SqlDbType.Char, 10);
            cm.Parameters.Add(p1);
            p1.Value = entity.PurchaseOrderNumber;

            SqlParameter p2 = new SqlParameter("@EBELP", SqlDbType.Char, 5);
            cm.Parameters.Add(p2);
            p2.Value = entity.PurchaseOrderScheduleSequence;

            SqlParameter p3 = new SqlParameter("@MATNR", SqlDbType.Char, 18);
            cm.Parameters.Add(p3);
            p3.Value = entity.MaterialNumber;

            SqlParameter p4 = new SqlParameter("@ETENR", SqlDbType.Char, 4);
            cm.Parameters.Add(p4);
            p4.Value = entity.PurchaseOrderScheduleSequence;

            SqlParameter p5 = new SqlParameter("@SLFDAT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p5);
            if (entity.OrderItemScheduleDate.HasValue)
                p5.Value = entity.OrderItemScheduleDate.Value;
            else
                p5.Value = DBNull.Value;

            SqlParameter p6 = new SqlParameter("@MENGE", SqlDbType.Decimal, 4);
            cm.Parameters.Add(p6);
            if (entity.DeliveryScheduleQuantity.HasValue)
                p6.Value = entity.DeliveryScheduleQuantity;
            else
                p6.Value = DBNull.Value;

            SqlParameter p7 = new SqlParameter("@EINDT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p7);
            if (entity.DeliveryDate.HasValue)
                p7.Value = entity.DeliveryDate;
            else
                p7.Value = DBNull.Value;

            SqlParameter p8 = new SqlParameter("@WEMNG", SqlDbType.Decimal, 4);
            cm.Parameters.Add(p8);
            if (entity.DeliveredQuantity.HasValue)
                p8.Value = entity.DeliveredQuantity;
            else
                p8.Value = DBNull.Value;

            SqlParameter p9 = new SqlParameter("@ACKDT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p9);
            if (entity.AcknowledgementDate.HasValue)
                p9.Value = entity.AcknowledgementDate;
            else
                p9.Value = DBNull.Value;

            SqlParameter p10 = new SqlParameter("@RECSTS", SqlDbType.Char, 1);
            cm.Parameters.Add(p10);
            p10.Value = entity.RecordStatus;

            SqlParameter p11 = new SqlParameter("@PRMDT", SqlDbType.BigInt, 8);
            cm.Parameters.Add(p11);
            if (entity.ExpeditingPromiseDate.HasValue)
                p11.Value = entity.ExpeditingPromiseDate;
            else
                p11.Value = DBNull.Value;
            
            cm.ExecuteNonQuery();

            if (epTran == null)
                if (connection.State != System.Data.ConnectionState.Closed) connection.Close();
        }
 public static EpTransaction BeginTransaction()
 {
     EpTransaction epTransaction = new EpTransaction();
     return epTransaction;
 }