当前位置: 首页>>代码示例>>C#>>正文


C# MsSqlPersistence.ExecuteCommand方法代码示例

本文整理汇总了C#中MsSqlPersistence.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# MsSqlPersistence.ExecuteCommand方法的具体用法?C# MsSqlPersistence.ExecuteCommand怎么用?C# MsSqlPersistence.ExecuteCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MsSqlPersistence的用法示例。


在下文中一共展示了MsSqlPersistence.ExecuteCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OrderSampleTestsSetStatus

        public int OrderSampleTestsSetStatus(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int sampleTestId, Identification identification, int? forceStatus = null)
        {
            try
            {
                int returnValue = 0;
                int remainingTimepoints = 0;
                int remainingOosRecords = 0;
                SampleTestStatus setStatus = SampleTestStatus.InProgress;
                string sql = string.Empty;

                if (forceStatus.IsNotNull())
                {
                    dbCommand.Parameters.Clear();
                    sql = @"
                        UPDATE orders_samples_tests
                        SET status = @Status, modified_by = @ModifiedBy
                        WHERE id = @ID;
                        ";
                    dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = sampleTestId;
                    dbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = forceStatus;
                    dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                    dbCommand.CommandText = sql;
                    returnValue = dbConnection.ExecuteCommand(dbCommand);
                    return returnValue;
                }

                dbCommand.Parameters.Clear();
                sql = @"
                        SELECT Count(timepoints.Id) as CountOfId
                        from orders_samples_tests_timepoints timepoints
                        LEFT JOIN  orders_samples_tests_timepoints_results AS result ON timepoints.id = result.parentid
                        LEFT JOIN  orders_samples_tests_timepoints_oos AS oos ON timepoints.oosid = oos.id
                        WHERE timepoints.parentid = @ID AND result.created_date IS NULL AND (oos.is_testing_complete = 'false' OR oos.is_testing_complete IS NULL)  ;
                        ";
                dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = sampleTestId;
                dbCommand.CommandText = sql;
                remainingTimepoints = (int)dbConnection.ExecuteScalar(dbCommand);

                sql = @"
                        SELECT Count(DISTINCT oos.Id) as CountOfId
                        from orders_samples_tests_timepoints_oos oos
                        LEFT JOIN  orders_samples_tests_timepoints AS timepoint ON timepoint.oosid = oos.id
                        WHERE timepoint.parentid = @ID and oos.status < 2 ;
                        ";
                dbCommand.CommandText = sql;
                remainingOosRecords = (int)dbConnection.ExecuteScalar(dbCommand);

                if (remainingTimepoints == 0 && remainingOosRecords == 0)
                    setStatus = SampleTestStatus.InProgress;

                dbCommand.Parameters.Clear();
                sql = @"
                        UPDATE orders_samples_tests
                        SET status = @Status, modified_by = @ModifiedBy
                        WHERE id = @ID;
                        ";
                dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = sampleTestId;
                dbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)setStatus;
                dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                dbCommand.CommandText = sql;
                returnValue = dbConnection.ExecuteCommand(dbCommand);
                //Return Total Number of Updated Records or Last Primary ID
                dbCommand.Parameters.Clear();
                return returnValue;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:70,代码来源:SampleDAO.cs

示例2: SaveClientDocuments

 public void SaveClientDocuments(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, Client client, int userId)
 {
     try {
         foreach (var doc in client.Documents) {
             if (doc.ClientDocumentId < 0) {
                 dbCommand.CommandType = CommandType.StoredProcedure;
                 dbCommand.CommandText = "uspInsertClientDocument";
                 dbCommand.Parameters.Clear();
                 dbCommand.Parameters.AddWithValue("@ClientId", client.ClientId);
                 dbCommand.Parameters.AddWithValue("@Filename", doc.Filename);
                 dbCommand.Parameters.AddWithValue("@DocumentData", Convert.FromBase64CharArray(doc.DocumentData.ToCharArray(), 0, doc.DocumentData.Length));
                 dbCommand.Parameters.AddWithValue("@CreatedBy", userId);
                 dbCommand.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                 doc.ClientDocumentId = dbConnection.ExecuteCommand(dbCommand);
             }else if (doc.IsDirty) {
                 dbCommand.CommandType = CommandType.StoredProcedure;
                 dbCommand.CommandText = "uspUpdateClientDocument";
                 dbCommand.Parameters.Clear();
                 dbCommand.Parameters.AddWithValue("@ClientDocumentId", doc.ClientDocumentId);
                 dbCommand.Parameters.AddWithValue("@ClientId", client.ClientId);
                 dbCommand.Parameters.AddWithValue("@ModifiedBy", userId);
                 dbCommand.Parameters.AddWithValue("@ModifiedDate", DateTime.Now);
                 dbCommand.Parameters.AddWithValue("@DeleteDate", doc.DeleteDate);
                 dbConnection.ExecuteCommand(dbCommand);
             }
         }
     }catch {
         throw;
     }
 }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:30,代码来源:ClientDAO.cs

示例3: SaveClientPricing

        public int SaveClientPricing(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ref Client client, int userId)
        {
            try {
                int returnValue = 0;
                foreach (ClientPricing price in client.Prices) {
                    if (price.IsDirty) {
                        SystemDAO.SaveChangeAudit<ClientPricing>(ref dbConnection, ref dbCommand,
                            GetClientPricing(price.ClientPricingId != -1 ? price.ClientPricingId : -1),
                            price,
                            ModuleNames.Clients,
                            client.Pk,
                            userId);

                        dbCommand.Parameters.Clear();
                        if (price.ClientPricingId <= 0) {
                            dbCommand.CommandType = CommandType.StoredProcedure;
                            dbCommand.CommandText = "uspInsertClientPricing";
                            dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                            dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = userId;
                        }else {
                            dbCommand.CommandType = CommandType.StoredProcedure;
                            dbCommand.CommandText = "uspUpdateClientPricing";
                            dbCommand.Parameters.Add("@ClientPricingId", System.Data.SqlDbType.Int).Value = price.ClientPricingId;
                            dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                            dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId;
                            dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = price.DeleteDate;
                        }
                        dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = client.ClientId;
                        dbCommand.Parameters.Add("@MethodId", System.Data.SqlDbType.Int).Value = price.MethodId;
                        dbCommand.Parameters.Add("@MethodNumberId", System.Data.SqlDbType.Int).Value = price.MethodNumberId;
                        dbCommand.Parameters.Add("@AnalyteId", System.Data.SqlDbType.Int).Value = price.AnalyteId;
                        dbCommand.Parameters.Add("@Description", System.Data.SqlDbType.Text, 100).Value = price.Description;
                        dbCommand.Parameters.Add("@Discount", System.Data.SqlDbType.Decimal).Value = price.Discount ?? 0;
                        dbCommand.Parameters.Add("@FlatRate", System.Data.SqlDbType.Decimal).Value = price.FlatRate ?? 0;

                        returnValue += dbConnection.ExecuteCommand(dbCommand);
                    }
                }
                //Return Total Number of Inserted or Updated Records
                return returnValue;
            }catch {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:44,代码来源:ClientDAO.cs

示例4: RemoveContacts

        public int RemoveContacts(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int clientId, int userId)
        {
            try
            {
                int returnValue = 0;

                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.CommandText = "uspRemoveContacts";
                dbCommand.Parameters.Clear();
                dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = clientId;
                dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now;
                dbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = userId;

                returnValue = dbConnection.ExecuteCommand(dbCommand);

                return returnValue;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:22,代码来源:ClientDAO.cs

示例5: SaveClientComplaint

        public int SaveClientComplaint(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ClientComplaint complaint, Identification identification)
        {
            try
            {
                int returnValue = 0;
                if (complaint.IsDirty)
                {
                    SystemDAO.SaveChangeAudit<ClientComplaint>(ref dbConnection, ref dbCommand,
                        GetClientComplaint(ref dbConnection, ref dbCommand, complaint.Pk),
                        complaint,
                        ModuleNames.Clients,
                        complaint.ClientId,
                        identification.UserId);

                    dbCommand.Parameters.Clear();
                    dbCommand.CommandType = CommandType.StoredProcedure;
                    dbCommand.CommandText = "uspUpdateClientComplaint";

                    dbCommand.Parameters.Add("@ClientComplaintId", System.Data.SqlDbType.Int).Value = complaint.ClientComplaintId;
                    dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = complaint.ClientId;
                    dbCommand.Parameters.Add("@ClassificationId", System.Data.SqlDbType.Int).Value = complaint.ClassificationId;
                    dbCommand.Parameters.Add("@StatusYN", System.Data.SqlDbType.Int).Value = (bool)complaint.StatusYN;
                    dbCommand.Parameters.Add("@Description", System.Data.SqlDbType.NVarChar, 100).Value = complaint.Description;
                    dbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.NVarChar, 100).Value = complaint.ARLNumber;
                    dbCommand.Parameters.Add("@RootCause", System.Data.SqlDbType.NVarChar, 100).Value = complaint.RootCause;
                    dbCommand.Parameters.Add("@NotifyUserId", System.Data.SqlDbType.Int).Value = complaint.NotifyUserId;
                    dbCommand.Parameters.Add("@CorrectiveAction", System.Data.SqlDbType.NVarChar, 100).Value = complaint.CorrectiveAction;
                    dbCommand.Parameters.Add("@CorrectiveActionDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                    dbCommand.Parameters.Add("@CorrectiveActionUserId", System.Data.SqlDbType.Int).Value = complaint.CorrectiveActionUserId;
                    dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = complaint.CorrectiveActionDate != null ? (SqlDateTime)complaint.CorrectiveActionDate : SqlDateTime.Null;
                    dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                    returnValue += dbConnection.ExecuteCommand(dbCommand);
                }
                return returnValue;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:40,代码来源:ClientDAO.cs

示例6: UpdateOrderSampleTestTimePointReportData

        public void UpdateOrderSampleTestTimePointReportData(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int timePointId, bool isOnReport, DateTime? reportDate, int reportBy)
        {
            string sql = string.Empty;
            try
            {
                sql = @"
                        UPDATE orders_samples_tests_timepoints
                        SET report_by = @ReportBy,  report_date = @ReportDate, is_on_report = @IsOnReport
                        WHERE id = @ID";
                dbCommand.Parameters.Clear();
                dbCommand.CommandText = sql;
                dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = timePointId;
                dbCommand.Parameters.Add("@ReportBy", System.Data.SqlDbType.Int).Value = reportBy;
                dbCommand.Parameters.Add("@ReportDate", System.Data.SqlDbType.DateTime).Value = reportDate;
                dbCommand.Parameters.Add("@IsOnReport", System.Data.SqlDbType.Bit).Value = isOnReport;

                dbConnection.ExecuteCommand(dbCommand);
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:23,代码来源:SampleDAO.cs

示例7: RemoveClient

        /// <summary>
        /// Remove Client
        /// </summary>
        /// <returns></returns>
        public int RemoveClient(int ClientId, int userId)
        {
            try {
                int rowsAffected;

                using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand) {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspRemoveClient";
                            DbCommand.Parameters.Clear();
                            DbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = ClientId;
                            DbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = userId;
                            DbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now;

                            rowsAffected = DbConnection.ExecuteCommand(DbCommand);

                            // ToDo Mark all Related Data Deleted
                            using (ClientDAO contactDao = new ClientDAO()) {
                                contactDao.RemoveContacts(ref dbConnection, ref dbCommand, ClientId, userId);
                            }

                            this.RemoveClientPricings(ref dbConnection, ref dbCommand, ClientId, userId);
                            this.RemoveClientNotes(ref dbConnection, ref dbCommand, ClientId, userId);
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return rowsAffected;
            }catch {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:38,代码来源:ClientDAO.cs

示例8: ReturnToOos

        public int ReturnToOos(TimePoint timePoint, SampleNote note, Identification identification)
        {
            int rowsAffected;

            using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true))
            {
                try
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            SystemDAO.SaveChangeAudit<TimePoint>(ref dbConnection, ref dbCommand,
                                "Return to OOS #:" + timePoint.OosId.ToString(),
                                "Status",
                                "Approved",
                                "Pending Investigation",
                                ModuleNames.Samples,
                                timePoint.ParentId,
                                timePoint.Pk,
                                identification.UserId);

                            this.SaveSampleNote(ref dbConnection, ref dbCommand, ref note, (int)timePoint.ParentId, identification);

                            string sql = string.Empty;

                            sql = "UPDATE orders_samples_tests_timepoints_oos " +
                                  "SET status = @Status " +
                                  "WHERE id = @ID";

                            DbCommand.Parameters.Clear();
                            DbCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = timePoint.OosId;
                            DbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)EnumOosStatus.Open;
                            DbCommand.CommandText = sql;
                            rowsAffected = DbConnection.ExecuteCommand(DbCommand);

                            OrderSampleTestsSetStatus(ref dbConnection, ref dbCommand, (int)timePoint.ParentId, identification);
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }

                    return rowsAffected;
                }
                catch
                {
                    throw;
                }
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:52,代码来源:SampleDAO.cs

示例9: SaveOrderInvoiceItems

 public int SaveOrderInvoiceItems(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, Invoice invoice, Identification identification)
 {
     try
     {
         int returnValue = 0;
         dbCommand.CommandText = @"
             INSERT INTO orders_invoices_items
                 (invoiceid,item_type,txn_lineid,item_recordid,accounting_code,line_description,quantity,class,amount,labnumber)
             VALUES
                 (@Invoiceid,@ItemType,@TxnLineid,@ItemRecordId,@AccountingCode,@LineDescription,@Quantity,@Class,@Amount,@Labnumber)
             ";
         foreach (InvoiceItem item in invoice.InvoiceItems)
         {
             dbCommand.Parameters.Clear();
             dbCommand.Parameters.Add("@Invoiceid", System.Data.SqlDbType.Int).Value = invoice.ARLNumber;
             dbCommand.Parameters.Add("@ItemType", System.Data.SqlDbType.Int).Value = (int)item.ItemType;
             //dbCommand.Parameters.Add("@ItemRecordId", System.Data.SqlDbType.Int).Value = item.ItemRecordId.Value;
             dbCommand.Parameters.Add("@TxnLineid", System.Data.SqlDbType.VarChar, 50).Value = item.TxnLineID ?? string.Empty;
             dbCommand.Parameters.Add("@AccountingCode", System.Data.SqlDbType.VarChar, 16).Value = item.AccountingCode ?? string.Empty;
             dbCommand.Parameters.Add("@LineDescription", System.Data.SqlDbType.VarChar, 4096).Value = item.Description ?? string.Empty;
             dbCommand.Parameters.Add("@Quantity", System.Data.SqlDbType.Int).Value = item.Quantity ?? 0;
             dbCommand.Parameters.Add("@Class", System.Data.SqlDbType.VarChar, 25).Value = item.Class ?? string.Empty;
             dbCommand.Parameters.Add("@Amount", System.Data.SqlDbType.Decimal).Value = item.Amount ?? 0;
             dbCommand.Parameters.Add("@Labnumber", System.Data.SqlDbType.Int).Value = item.ARLNumber;
             returnValue += dbConnection.ExecuteCommand(dbCommand);
         }
         return returnValue;
     }
     catch
     {
         throw;
     }
 }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:33,代码来源:SampleDAO.cs

示例10: RemoveOrderSampleTests

        public int RemoveOrderSampleTests(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, dynamic parentId, int userId)
        {
            try
            {
                int returnValue = 0;
                string sql = string.Empty;
                if (parentId is int)
                {
                    sql = "UPDATE orders_samples_tests " +
                          "SET delete_date = @DeleteDate, modified_by = @UserID " +
                          "WHERE Parentid = @ParentId";

                    dbCommand.Parameters.Clear();
                    dbCommand.Parameters.Add("@ParentId", System.Data.SqlDbType.Int).Value = parentId;
                    dbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = userId;
                    dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now;
                    dbCommand.CommandText = sql;
                    returnValue = dbConnection.ExecuteCommand(dbCommand);
                }
                else
                {
                    sql = string.Format("UPDATE orders_samples_tests " +
                                        "SET delete_date = @DeleteDate, modified_by = @UserID " +
                                        "WHERE parentid in ({0})", String.Join(",", parentId.Count() > 0 ? parentId : new List<int>() { -1 }));

                    dbCommand.Parameters.Clear();
                    dbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = userId;
                    dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now;
                    dbCommand.CommandText = sql;

                    returnValue = dbConnection.ExecuteCommand(dbCommand);
                }

                return returnValue;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:40,代码来源:SampleDAO.cs

示例11: RemoveSample

        public int RemoveSample(int arlNumber, Identification identification)
        {
            try
            {
                int rowsAffected;
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true))
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspRemoveSample";
                            DbCommand.Parameters.Clear();

                            DbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.Int).Value = arlNumber;
                            DbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now;
                            DbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;

                            rowsAffected = DbConnection.ExecuteCommand(DbCommand);

                            this.RemoveSampleAnalytes(ref dbConnection, ref dbCommand, arlNumber, identification.UserId);
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }
                }
                return rowsAffected;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:36,代码来源:SampleDAO.cs

示例12: RemoveOrderSampleTest

        public int RemoveOrderSampleTest(int id, int userId)
        {
            int rowsAffected;

            using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true))
            {
                try
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            string sql = string.Empty;

                            sql = "UPDATE orders_samples_tests " +
                                  "SET delete_date = @DeleteDate, modified_by = @ModifiedBy " +
                                  "WHERE id = @ID";

                            DbCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = id;
                            DbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = System.DateTime.Now;
                            DbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = userId;
                            DbCommand.CommandText = sql;

                            rowsAffected = DbConnection.ExecuteCommand(DbCommand);
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }

                    return rowsAffected;
                }
                catch
                {
                    throw;
                }
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:39,代码来源:SampleDAO.cs

示例13: ReinstateOrderSampleTest

        public int ReinstateOrderSampleTest(int id, SampleNote note, Identification identificaion)
        {
            int rowsAffected;

            using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true))
            {
                try
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            this.SaveSampleNote(ref dbConnection, ref dbCommand, ref note, id, identificaion);

                            string sql = string.Empty;

                            sql = "UPDATE orders_samples_tests " +
                                  "SET status = @Status, modified_by = @ModifiedBy " +
                                  "WHERE id = @ID";

                            DbCommand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = id;
                            DbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)SampleTestStatus.InProgress;
                            DbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identificaion.UserId;
                            DbCommand.CommandText = sql;

                            rowsAffected = DbConnection.ExecuteCommand(DbCommand);
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }

                    return rowsAffected;
                }
                catch
                {
                    throw;
                }
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:41,代码来源:SampleDAO.cs

示例14: OrderSetStatus

        public int OrderSetStatus(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int id, Identification identification, int? forceStatus = null)
        {
            try
            {
                int returnValue = 0;
                int remainingInvoicesPending = 0;
                EnumOrderStatus setStatus = EnumOrderStatus.Open;
                string sql = string.Empty;

                if (forceStatus.IsNotNull())
                {
                    dbCommand.Parameters.Clear();
                    sql = @"
                        UPDATE orders
                        SET status = @Status, modified_by = @ModifiedBy
                        WHERE id = @ID;
                        ";
                    dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = id;
                    dbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = forceStatus;
                    dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                    dbCommand.CommandText = sql;
                    returnValue = dbConnection.ExecuteCommand(dbCommand);
                    return returnValue;
                }

                dbCommand.Parameters.Clear();
                sql = @"
                        SELECT Count(DISTINCT tests.Id) as CountOfId
                        from orders
                        LEFT JOIN orders_samples_tests AS tests ON tests.parentid = orders.id
                        WHERE
                        orders.id = @Id AND
                        (orders.delete_date IS NULL AND orders.status < @OrderInvoiced AND
                        tests.delete_date IS NULL AND tests.status != @TestInvoiced)
                        ;
                        ";
                dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = id;
                dbCommand.Parameters.Add("@OrderInvoiced", System.Data.SqlDbType.Int).Value = EnumOrderStatus.Invoiced;
                dbCommand.Parameters.Add("@TestInvoiced", System.Data.SqlDbType.Int).Value = SampleTestStatus.Completed;
                dbCommand.CommandText = sql;
                remainingInvoicesPending = (int)dbConnection.ExecuteScalar(dbCommand);

                if (remainingInvoicesPending == 0)
                    setStatus = EnumOrderStatus.Invoiced;
                else return 0;

                dbCommand.Parameters.Clear();
                sql = @"
                        UPDATE orders
                        SET status = @Status, modified_by = @ModifiedBy
                        WHERE id = @ID;
                        ";
                dbCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = id;
                dbCommand.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value = (int)setStatus;
                dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                dbCommand.CommandText = sql;
                returnValue = dbConnection.ExecuteCommand(dbCommand);
                dbCommand.Parameters.Clear();
                return returnValue;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:65,代码来源:SampleDAO.cs

示例15: SaveSampleNotes

        public int SaveSampleNotes(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ref Sample sample, Identification identification)
        {
            try
            {
                int returnValue = 0;
                foreach (SampleNote note in sample.SampleNotes)
                {
                    if (note.IsDirty)
                    {
                        dbCommand.CommandType = CommandType.StoredProcedure;
                        dbCommand.Parameters.Clear();

                        if (note.SampleNoteId <= 0)
                        {
                            dbCommand.CommandText = "uspInsertSampleNote";
                            dbCommand.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                            dbCommand.Parameters.Add("@CreatedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                        }
                        else
                        {
                            /*SystemDAO.SaveChangeAudit<SampleNote>(ref dbConnection, ref dbCommand,
                                GetSampleNote(ref dbConnection, ref dbCommand, note.Pk, identification),
                                note,
                                ModuleNames.Samples,
                                sample.Pk,
                                identification.UserId); */
                            dbCommand.Parameters.Clear();
                            dbCommand.CommandText = "uspUpdateSampleNote";
                            dbCommand.Parameters.Add("@SampleNoteId", System.Data.SqlDbType.Int).Value = note.SampleNoteId;
                            dbCommand.Parameters.Add("@DeleteDate", System.Data.SqlDbType.DateTime).Value = note.DeleteDate.HasValue ? note.DeleteDate.Value : SqlDateTime.Null;
                            dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                            dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                        }

                        dbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.Int).Value = sample.ARLNumber;
                        dbCommand.Parameters.Add("@SampleTestId", System.Data.SqlDbType.Int).Value = note.SampleTestId ?? note.SampleTestId;
                        dbCommand.Parameters.Add("@Note", System.Data.SqlDbType.NVarChar, 4000).Value = note.Note ?? SqlString.Null;
                        dbCommand.Parameters.Add("@IncludeOnWOYN", System.Data.SqlDbType.Bit).Value = note.IncludeOnWOYN;
                        dbCommand.Parameters.Add("@IncludeOnCOAYN", System.Data.SqlDbType.Bit).Value = note.IncludeOnCOAYN;
                        dbCommand.Parameters.Add("@BillGroup", System.Data.SqlDbType.Int).Value = note.BillGroup;

                        returnValue += dbConnection.ExecuteCommand(dbCommand);
                    }
                }
                //Return Total Number of Inserted or Updated Records
                return returnValue;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:52,代码来源:SampleDAO.cs


注:本文中的MsSqlPersistence.ExecuteCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。