Esempio n. 1
0
        public int LoadPartnerOrder(PartnerOrder obj)
        {
            string sql = @"Select 
                              [OrderID]
                             ,[OrderNo]
                             ,[OrderType]
                             ,[OutOrderNo]
                             ,[PartnerID]
                             ,[PartnerName]
                             ,[CustomerID]
                             ,[CustomerName]
                             ,[SalesMan]
                             ,[Address]
                             ,[Mobile]
                             ,[BookingDate]
                             ,[ShipDate]
                             ,[Status]
                             ,[StepNo]
                             ,[Remark]
                             ,[AttachmentFile]
                             ,[Created]
                             ,[CreatedBy]
                             ,[Modified]
                             ,[ModifiedBy]
                       From [BE_PartnerOrder] With(NoLock) Where OrderID=@OrderID";

            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pOrderID = new SqlParameter("OrderID", Convert2DBnull(obj.OrderID));

            pOrderID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pOrderID);

            int           ret = 0;
            SqlDataReader dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["OrderID"]))
                    {
                        obj.OrderID = (Guid)dr["OrderID"];
                    }
                    if (!Convert.IsDBNull(dr["OrderNo"]))
                    {
                        obj.OrderNo = (string)dr["OrderNo"];
                    }
                    if (!Convert.IsDBNull(dr["OrderType"]))
                    {
                        obj.OrderType = (string)dr["OrderType"];
                    }
                    if (!Convert.IsDBNull(dr["OutOrderNo"]))
                    {
                        obj.OutOrderNo = (string)dr["OutOrderNo"];
                    }
                    if (!Convert.IsDBNull(dr["PartnerID"]))
                    {
                        obj.PartnerID = (Guid)dr["PartnerID"];
                    }
                    if (!Convert.IsDBNull(dr["PartnerName"]))
                    {
                        obj.PartnerName = (string)dr["PartnerName"];
                    }
                    if (!Convert.IsDBNull(dr["CustomerID"]))
                    {
                        obj.CustomerID = (Guid)dr["CustomerID"];
                    }
                    if (!Convert.IsDBNull(dr["CustomerName"]))
                    {
                        obj.CustomerName = (string)dr["CustomerName"];
                    }
                    if (!Convert.IsDBNull(dr["SalesMan"]))
                    {
                        obj.SalesMan = (string)dr["SalesMan"];
                    }
                    if (!Convert.IsDBNull(dr["Address"]))
                    {
                        obj.Address = (string)dr["Address"];
                    }
                    if (!Convert.IsDBNull(dr["Mobile"]))
                    {
                        obj.Mobile = (string)dr["Mobile"];
                    }
                    if (!Convert.IsDBNull(dr["BookingDate"]))
                    {
                        obj.BookingDate = (DateTime)dr["BookingDate"];
                    }
                    if (!Convert.IsDBNull(dr["ShipDate"]))
                    {
                        obj.ShipDate = (DateTime)dr["ShipDate"];
                    }
                    if (!Convert.IsDBNull(dr["Status"]))
                    {
                        obj.Status = (string)dr["Status"];
                    }
                    if (!Convert.IsDBNull(dr["StepNo"]))
                    {
                        obj.StepNo = (int)dr["StepNo"];
                    }
                    if (!Convert.IsDBNull(dr["Remark"]))
                    {
                        obj.Remark = (string)dr["Remark"];
                    }
                    if (!Convert.IsDBNull(dr["AttachmentFile"]))
                    {
                        obj.AttachmentFile = (string)dr["AttachmentFile"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        obj.Created = (DateTime)dr["Created"];
                    }
                    if (!Convert.IsDBNull(dr["CreatedBy"]))
                    {
                        obj.CreatedBy = (string)dr["CreatedBy"];
                    }
                    if (!Convert.IsDBNull(dr["Modified"]))
                    {
                        obj.Modified = (DateTime)dr["Modified"];
                    }
                    if (!Convert.IsDBNull(dr["ModifiedBy"]))
                    {
                        obj.ModifiedBy = (string)dr["ModifiedBy"];
                    }
                    ret += 1;
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
Esempio n. 2
0
        public int UpdatePartnerOrderByOrderID(PartnerOrder obj)
        {
            string sql = @"Update [BE_PartnerOrder] Set
                              [OrderNo]=@OrderNo
                             ,[OrderType]=@OrderType
                             ,[OutOrderNo]=@OutOrderNo
                             ,[PartnerID]=@PartnerID
                             ,[PartnerName]=@PartnerName
                             ,[CustomerID]=@CustomerID
                             ,[CustomerName]=@CustomerName
                             ,[SalesMan]=@SalesMan
                             ,[Address]=@Address
                             ,[Mobile]=@Mobile
                             ,[BookingDate]=@BookingDate
                             ,[ShipDate]=@ShipDate
                             ,[Status]=@Status
                             ,[StepNo]=@StepNo
                             ,[Remark]=@Remark
                             ,[AttachmentFile]=@AttachmentFile
                             ,[Created]=@Created
                             ,[CreatedBy]=@CreatedBy
                             ,[Modified]=@Modified
                             ,[ModifiedBy]=@ModifiedBy
                          Where OrderID=@OrderID";

            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pOrderID = new SqlParameter("OrderID", Convert2DBnull(obj.OrderID));

            pOrderID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pOrderID);

            SqlParameter pOrderNo = new SqlParameter("OrderNo", Convert2DBnull(obj.OrderNo));

            pOrderNo.SqlDbType = SqlDbType.VarChar;
            cmd.Parameters.Add(pOrderNo);

            SqlParameter pOrderType = new SqlParameter("OrderType", Convert2DBnull(obj.OrderType));

            pOrderType.SqlDbType = SqlDbType.VarChar;
            cmd.Parameters.Add(pOrderType);

            SqlParameter pOutOrderNo = new SqlParameter("OutOrderNo", Convert2DBnull(obj.OutOrderNo));

            pOutOrderNo.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pOutOrderNo);

            SqlParameter pPartnerID = new SqlParameter("PartnerID", Convert2DBnull(obj.PartnerID));

            pPartnerID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pPartnerID);

            SqlParameter pPartnerName = new SqlParameter("PartnerName", Convert2DBnull(obj.PartnerName));

            pPartnerName.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pPartnerName);

            SqlParameter pCustomerID = new SqlParameter("CustomerID", Convert2DBnull(obj.CustomerID));

            pCustomerID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pCustomerID);

            SqlParameter pCustomerName = new SqlParameter("CustomerName", Convert2DBnull(obj.CustomerName));

            pCustomerName.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCustomerName);

            SqlParameter pSalesMan = new SqlParameter("SalesMan", Convert2DBnull(obj.SalesMan));

            pSalesMan.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pSalesMan);

            SqlParameter pAddress = new SqlParameter("Address", Convert2DBnull(obj.Address));

            pAddress.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pAddress);

            SqlParameter pMobile = new SqlParameter("Mobile", Convert2DBnull(obj.Mobile));

            pMobile.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pMobile);

            SqlParameter pBookingDate = new SqlParameter("BookingDate", Convert2DBnull(obj.BookingDate));

            pBookingDate.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pBookingDate);

            SqlParameter pShipDate = new SqlParameter("ShipDate", Convert2DBnull(obj.ShipDate));

            pShipDate.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pShipDate);

            SqlParameter pStatus = new SqlParameter("Status", Convert2DBnull(obj.Status));

            pStatus.SqlDbType = SqlDbType.Char;
            cmd.Parameters.Add(pStatus);

            SqlParameter pStepNo = new SqlParameter("StepNo", Convert2DBnull(obj.StepNo));

            pStepNo.SqlDbType = SqlDbType.Int;
            cmd.Parameters.Add(pStepNo);

            SqlParameter pRemark = new SqlParameter("Remark", Convert2DBnull(obj.Remark));

            pRemark.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pRemark);

            SqlParameter pAttachmentFile = new SqlParameter("AttachmentFile", Convert2DBnull(obj.AttachmentFile));

            pAttachmentFile.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pAttachmentFile);

            SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created));

            pCreated.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pCreated);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy));

            pCreatedBy.SqlDbType = SqlDbType.VarChar;
            cmd.Parameters.Add(pCreatedBy);

            SqlParameter pModified = new SqlParameter("Modified", Convert2DBnull(obj.Modified));

            pModified.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pModified);

            SqlParameter pModifiedBy = new SqlParameter("ModifiedBy", Convert2DBnull(obj.ModifiedBy));

            pModifiedBy.SqlDbType = SqlDbType.VarChar;
            cmd.Parameters.Add(pModifiedBy);

            return(cmd.ExecuteNonQuery());
        }