/// <summary>
 /// Gets the detail items.
 /// </summary>
 /// <param name="STVLogID">The STV log ID.</param>
 /// <returns></returns>
 public static DataTable GetDetailItems(int STVLogID)
 {
     var query = HCMIS.Repository.Queries.Issue.SelectGetDetailItems(STVLogID);
     Issue log = new Issue();
     log.LoadFromRawSql(query);
     return log.DataTable;
 }
 public static int GetConfirmedInvoices()
 {
     var query = HCMIS.Repository.Queries.Issue.SelectGetConfirmedInvoices();
     var iss = new Issue();
     iss.LoadFromRawSql(query);
     return Convert.ToInt32(iss.GetColumn("Value"));
 }
        /// <summary>
        /// Gets the last printed ID.
        /// </summary>
        /// <param name="storeID">The store ID.</param>
        /// <param name="paymentTypeID">The payment type ID.</param>
        /// <returns></returns>

        public static int GetLastPrintedIDByPaymentTypeID(int activityId, int?paymentTypeId)
        {
            Issue  s     = new Issue();
            string query = "";

            query = HCMIS.Repository.Queries.Issue.SelectGetLastPrintedIDByPaymentTypeID(activityId, paymentTypeId);

            s.LoadFromRawSql(query);
            int calculatedId;

            try
            {
                calculatedId = int.Parse(s.GetColumn("IDPrinted").ToString());
            }
            catch
            {
                calculatedId = 0;
            }


            int startingPointID = 0;// A provision in case the STV or invoice number is required to start from a certain number.

            if (calculatedId <= startingPointID && calculatedId != 0)
            {
                return(startingPointID);
            }
            else
            {
                return(calculatedId);
            }
        }
        /// <summary>
        /// What this fixes: The code for the STVLog had put the PickLitDetailID in the table instead of the PicklistID
        /// </summary>
        public static void FixInconsistencies()
        {
            var query = HCMIS.Repository.Queries.Issue.UpdateFixInconsistencies();

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
        }
        /// <summary>
        /// Gets the issue details.
        /// </summary>
        /// <param name="_stvID">The _STV ID.</param>
        /// <returns></returns>
        public static object GetIssueDetails(int _stvID)
        {
            var query = HCMIS.Repository.Queries.Issue.SelectGetIssueDetails(_stvID);

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
            return(s.DefaultView);
        }
        public Issue GetIssueByOrderID(int orderid)
        {
            var query = HCMIS.Repository.Queries.Issue.SelectIssueByOrderID(orderid);
            var iss   = new Issue();

            iss.LoadFromRawSql(query);
            return(iss);
        }
        /// <summary>
        /// Gets the log for facility.
        /// </summary>
        /// <param name="storeID">The store ID.</param>
        /// <param name="facilityID">The facility ID.</param>
        /// <returns></returns>
        public static DataTable GetLogForFacility(int storeID, int facilityID)
        {
            var query = HCMIS.Repository.Queries.Issue.SelectGetLogForFacility(storeID, facilityID);

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
            return(s.DataTable);
        }
 /// <summary>
 /// Gets the delivery notes to be converted.
 /// </summary>
 /// <param name="storeId">The store id.</param>
 /// <returns></returns>
 public static DataTable GetDeliveryNotesToBeConverted(int storeId)
 {
     // Now ... Consider the user's previlages
     var query = HCMIS.Repository.Queries.Issue.SelectGetDeliveryNotesToBeConverted(storeId);
     Issue stvLog = new Issue();
     stvLog.LoadFromRawSql(query);
     return stvLog.DataTable;
 }
        public static DataRow GetVisitHistoryForFacility(string facilityname)
        {
            var query = HCMIS.Repository.Queries.Issue.SelectGetVisitHistoryForFacility(facilityname);

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
            return(s.DataTable.Rows.Count > 0 ? s.DataTable.Rows[0] : null);
        }
        /// <summary>
        /// Gets the detail items.
        /// </summary>
        /// <param name="STVLogID">The STV log ID.</param>
        /// <returns></returns>
        public static DataTable GetDetailItems(int STVLogID)
        {
            var   query = HCMIS.Repository.Queries.Issue.SelectGetDetailItems(STVLogID);
            Issue log   = new Issue();

            log.LoadFromRawSql(query);
            return(log.DataTable);
        }
        public static DataView GetIssueDetailByFacility(int accountId, DateTime fromdate, DateTime toDate, int facilityID)
        {
            var query = HCMIS.Repository.Queries.Issue.SelectGetIssueDetailByFacility(accountId, fromdate, toDate, facilityID);
            var iss   = new Issue();

            iss.LoadFromRawSql(query);
            return(iss.DefaultView);
        }
        public static int GetConfirmedInvoices()
        {
            var query = HCMIS.Repository.Queries.Issue.SelectGetConfirmedInvoices();
            var iss   = new Issue();

            iss.LoadFromRawSql(query);
            return(Convert.ToInt32(iss.GetColumn("Value")));
        }
        /// <summary>
        /// Gets the delivery notes to be converted.
        /// </summary>
        /// <param name="storeId">The store id.</param>
        /// <returns></returns>
        public static DataTable GetDeliveryNotesToBeConverted(int storeId)
        {
            // Now ... Consider the user's previlages
            var   query  = HCMIS.Repository.Queries.Issue.SelectGetDeliveryNotesToBeConverted(storeId);
            Issue stvLog = new Issue();

            stvLog.LoadFromRawSql(query);
            return(stvLog.DataTable);
        }
        public static DataTable Search(string searchString, string type)
        {
            int paymentType = (type == "Cash")
                                  ? PaymentType.Constants.CASH
                                  : (type == "Credit") ? PaymentType.Constants.CREDIT : PaymentType.Constants.STV;
            var   query = HCMIS.Repository.Queries.Issue.SelectSearch(searchString, type, paymentType);
            Issue log   = new Issue();

            log.LoadFromRawSql(query);
            return(log.DataTable);
        }
        /// <summary>
        /// Marks as dispatched.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="prePrintedSTV">The pre printed STV.</param>
        /// <returns></returns>
        public bool MarkAsDispatched(int userID, int?prePrintedSTV)
        {
            if (!this.IsColumnNull("VoidRequest"))
            {
                if ((this.VoidRequest && this.IsColumnNull("VoidApprovedByUserID"))) //If the approver hasn't acted on the void request.
                {
                    return(false);
                }
            }
            //Mark the NoOfPackIssued equal to the NoOfPack.  Discrepancies are supposed to be saved after this function has finished running.
            var query = HCMIS.Repository.Queries.Issue.UpdateMarkAsDispatched(userID, this.ID);

            var queryConfirmIssue = HCMIS.Repository.Queries.Issue.UpdateMarkAsDispatched(this.ID);

            if (prePrintedSTV.HasValue)
            {
                this.PrePrintedInvoiceNo = prePrintedSTV.Value;
                this.Save();
            }

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
            s.LoadFromRawSql(queryConfirmIssue);

            BLL.IssueDoc isDoc = new IssueDoc();
            isDoc.Where.STVID.Value = this.ID;
            isDoc.Query.Load();
            if (isDoc.RowCount > 0)
            {
                int       orderID = isDoc.OrderID;
                BLL.Order ord     = new Order();
                ord.LoadByPrimaryKey(orderID);
                if (ord.RowCount > 0)
                {
                    ord.ChangeStatus(OrderStatus.Constant.DISPATCH_CONFIRMED, CurrentContext.UserId);
                    ord.Save();
                }
            }

            return(true);
        }
        /// <summary>
        /// Gets the log for
        /// </summary>
        /// <param name="refNo">The ref no.</param>
        /// <returns></returns>
        public static string GetLogFor(string refNo)
        {
            Issue log = new Issue();

            log.LoadFromRawSql(HCMIS.Repository.Queries.Issue.SelectGetLogFor(refNo));
            if (log.RowCount == 0)
            {
                // Indicate that this is a number from the old Pick list numbering logic
                return("O-" + refNo);
            }
            return(log.ID.ToString("00000"));
        }
        //public void GetTotalPrintedIssues


        public void SaveInvoiceChecked()
        {
            this.Rewind();
            while (!this.EOF)
            {
                if (Convert.ToBoolean(this.GetColumn("IsChanged")))
                {
                    var       query = HCMIS.Repository.Queries.Issue.UpdateSaveInvoiceChecked(this.IsChecked, this.ID);
                    BLL.Issue iss   = new Issue();
                    iss.LoadFromRawSql(query);
                }
                this.MoveNext();
            }
        }
 /// <summary>
 /// Gets the log for
 /// </summary>
 /// <param name="refNo">The ref no.</param>
 /// <returns></returns>
 public static string GetLogFor(string refNo)
 {
     Issue log = new Issue();
     log.LoadFromRawSql(HCMIS.Repository.Queries.Issue.SelectGetLogFor(refNo));
     if (log.RowCount == 0)
     {
         // Indicate that this is a number from the old Pick list numbering logic
         return "O-" + refNo;
     }
     return log.ID.ToString("00000");
 }
 /// <summary>
 /// What this fixes: The code for the STVLog had put the PickLitDetailID in the table instead of the PicklistID
 /// </summary>
 public static void FixInconsistencies()
 {
     var query = HCMIS.Repository.Queries.Issue.UpdateFixInconsistencies();
     BLL.Issue s = new Issue();
     s.LoadFromRawSql(query);
 }
 public static DataRow GetVisitHistoryForFacility(string facilityname)
 {
     var query = HCMIS.Repository.Queries.Issue.SelectGetVisitHistoryForFacility(facilityname);
     BLL.Issue s = new Issue();
     s.LoadFromRawSql(query);
     return s.DataTable.Rows.Count > 0 ? s.DataTable.Rows[0] : null;
 }
 /// <summary>
 /// Gets the log for facility.
 /// </summary>
 /// <param name="storeID">The store ID.</param>
 /// <param name="facilityID">The facility ID.</param>
 /// <returns></returns>
 public static DataTable GetLogForFacility(int storeID, int facilityID)
 {
     var query = HCMIS.Repository.Queries.Issue.SelectGetLogForFacility(storeID, facilityID);
     BLL.Issue s = new Issue();
     s.LoadFromRawSql(query);
     return s.DataTable;
 }
 public static DataView GetIssueDetailByFacility(int accountId,DateTime fromdate,DateTime toDate,int facilityID)
 {
     var query = HCMIS.Repository.Queries.Issue.SelectGetIssueDetailByFacility(accountId, fromdate, toDate, facilityID);
     var iss = new Issue();
     iss.LoadFromRawSql(query);
     return iss.DefaultView;
 }
 //public void GetTotalPrintedIssues
 public void SaveInvoiceChecked()
 {
     this.Rewind();
     while (!this.EOF)
     {
         if (Convert.ToBoolean(this.GetColumn("IsChanged")))
         {
             var query = HCMIS.Repository.Queries.Issue.UpdateSaveInvoiceChecked(this.IsChecked, this.ID);
             BLL.Issue iss = new Issue();
             iss.LoadFromRawSql(query);
         }
         this.MoveNext();
     }
 }
        /// <summary>
        /// Gets the last printed ID.
        /// </summary>
        /// <param name="storeID">The store ID.</param>
        /// <param name="paymentTypeID">The payment type ID.</param>
        /// <returns></returns>
        public static int GetLastPrintedIDByPaymentTypeID(int activityId, int? paymentTypeId)
        {
            Issue s = new Issue();
            string query = "";

            query = HCMIS.Repository.Queries.Issue.SelectGetLastPrintedIDByPaymentTypeID(activityId, paymentTypeId);

            s.LoadFromRawSql(query);
            int calculatedId;
            try
            {
                calculatedId = int.Parse(s.GetColumn("IDPrinted").ToString());
            }
            catch
            {
                calculatedId = 0;
            }

            int startingPointID = 0;// A provision in case the STV or invoice number is required to start from a certain number.
            if (calculatedId <= startingPointID && calculatedId != 0)
                return startingPointID;
            else
                return calculatedId;
        }
 public Issue GetIssueByOrderID(int orderid)
 {
     var query = HCMIS.Repository.Queries.Issue.SelectIssueByOrderID(orderid);
     var iss = new Issue();
     iss.LoadFromRawSql(query);
     return iss;
 }
        /// <summary>
        /// Marks as dispatched.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="prePrintedSTV">The pre printed STV.</param>
        /// <returns></returns>
        public bool MarkAsDispatched(int userID, int? prePrintedSTV)
        {
            if (!this.IsColumnNull("VoidRequest"))
            {
                if ((this.VoidRequest && this.IsColumnNull("VoidApprovedByUserID"))) //If the approver hasn't acted on the void request.
                {
                    return false;
                }
            }
            //Mark the NoOfPackIssued equal to the NoOfPack.  Discrepancies are supposed to be saved after this function has finished running.
            var query = HCMIS.Repository.Queries.Issue.UpdateMarkAsDispatched(userID, this.ID);

            var queryConfirmIssue = HCMIS.Repository.Queries.Issue.UpdateMarkAsDispatched(this.ID);

            if (prePrintedSTV.HasValue)
            {
                this.PrePrintedInvoiceNo = prePrintedSTV.Value;
                this.Save();
            }

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
            s.LoadFromRawSql(queryConfirmIssue);

            BLL.IssueDoc isDoc = new IssueDoc();
            isDoc.Where.STVID.Value = this.ID;
            isDoc.Query.Load();
            if (isDoc.RowCount > 0)
            {
                int orderID = isDoc.OrderID;
                BLL.Order ord = new Order();
                ord.LoadByPrimaryKey(orderID);
                if (ord.RowCount > 0)
                {
                    ord.ChangeStatus(OrderStatus.Constant.DISPATCH_CONFIRMED,CurrentContext.UserId);
                    ord.Save();
                }
            }

            return true;
        }
        /// <summary>
        /// Gets the issue details.
        /// </summary>
        /// <param name="_stvID">The _STV ID.</param>
        /// <returns></returns>
        public static object GetIssueDetails(int _stvID)
        {
            var query = HCMIS.Repository.Queries.Issue.SelectGetIssueDetails(_stvID);

            BLL.Issue s = new Issue();
            s.LoadFromRawSql(query);
            return s.DefaultView;
        }
 public static DataTable Search(string searchString, string type)
 {
     int paymentType = (type == "Cash")
                           ? PaymentType.Constants.CASH
                           : (type == "Credit") ? PaymentType.Constants.CREDIT : PaymentType.Constants.STV;
     var query = HCMIS.Repository.Queries.Issue.SelectSearch(searchString, type, paymentType);
     Issue log = new Issue();
     log.LoadFromRawSql(query);
     return log.DataTable;
 }