Ejemplo n.º 1
0
 public long[] GetMailTemplatesIdUsingQuery()
 {
     try
     {
         string query = "Select Distinct MailTemplateId from MailActivity where ScheduleNextDate = CAST(GETDATE() AS DATE) AND IsActive= 1";
         long[] empty = new long[5];
         IList  list  = PSF.ExecuteSql(query);
         if (list != null && list[0] != null)
         {
             long[] longlist = new long[list.Count];
             int    i        = 0;
             foreach (var item in list)
             {
                 longlist[i] = Convert.ToInt64(item);
                 i++;
             }
             return(longlist);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DateTime GetApprovedDeliveryDateById(long OrderId)
 {
     try
     {
         //string query = "SELECT TOP 1 ActualDeliveryDate from Deliverynote WHERE DeliveryNoteType='Main DN' AND OrderId='" + OrderId + "'";
         //string query = "SELECT MAX(DeliveredDate) as Deliverydate FROM PODItems where OrderId='" + OrderId + "'";
         string query = "SELECT ApprovedDeliverydate FROM dbo.GetActualDeliveryDate_Vw where OrderId='" + OrderId + "'";
         IList  list  = PSF.ExecuteSql(query);
         if (list != null && list.Count > 0 && list[0] != null)
         {
             return(Convert.ToDateTime(list[0])); //list[0] = "0";
         }
         else
         {
             string GetApprovedDeliveryDateQuery = "SELECT ExpectedDeliveryDate FROM dbo.Orders WHERE OrderId=" + OrderId;
             IList  GetApprovedDeliveryDatelist  = PSF.ExecuteSql(GetApprovedDeliveryDateQuery);
             if (GetApprovedDeliveryDatelist != null && GetApprovedDeliveryDatelist.Count > 0 && GetApprovedDeliveryDatelist[0] != null)
             {
                 return(Convert.ToDateTime(GetApprovedDeliveryDatelist[0])); //list[0] = "0";
             }
             else
             {
                 return(DateTime.Now);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void InsertPOMasterDetailsByRequestId_sp(long RequestIds)
 {
     try
     {
         //string POInsertQuery = "EXEC dbo.InsertPOMasterDetailsByRequestId_sp " + RequestIds;
         string POInsertQuery = "EXEC dbo.Inventory_InsertPurchaseOrderandOrderItemByRequestId_sp " + RequestIds;
         PSF.ExecuteSql(POInsertQuery);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public long GetCurrentIntent(string table)
 {
     try
     {
         string query = "select IDENT_CURRENT('" + table + "')";
         IList  list  = PSF.ExecuteSql(query);
         if (list != null && list[0] != null)
         {
             return(Convert.ToInt64(list[0].ToString()) + 1); //list[0] = "0";
         }
         else
         {
             return(0);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public IList <TroopsReport> GetTroopsReportbyFlag(string PeriodYear, string Period, string Sector, string ContingentType, string Location, string Flag, string Criteria)
        {
            try
            {
                string query = "Exec TroopReport @spPeriodYear='" + PeriodYear;
                query = query + "', @spPeriod='" + Period;
                query = query + "', @spFlag='" + Flag + "'";
                if (Sector == null)
                {
                    query = query + ", @spSector=null";
                }
                else
                {
                    query = query + ", @spSector='" + Sector + "'";
                }
                if (ContingentType == null)
                {
                    query = query + ", @spContingentType=null";
                }
                else
                {
                    query = query + ", @spContingentType='" + ContingentType + "'";
                }
                if (Location == null)
                {
                    query = query + ", @spLocation=null";
                }
                else
                {
                    query = query + ", @spLocation='" + Location + "'";
                }
                if (Criteria == null)
                {
                    query = query + ", @spCriteria=null";
                }

                else
                {
                    query = query + ", @spCriteria='" + Criteria + "'";
                }

                IList list = PSF.ExecuteSql(query);

                IList <TroopsReport> periodlist = new List <TroopsReport>();
                switch (Flag)
                {
                case "PERIODYEAR":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.PeriodYear     = Convert.ToString(((object[])(obj))[1]);
                        troops.SumofTroops    = Convert.ToDecimal(((object[])(obj))[2]);
                        periodlist.Add(troops);
                    }
                    break;

                case "PERIOD":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.PeriodYear     = Convert.ToString(((object[])(obj))[1]);
                        troops.Period         = Convert.ToString(((object[])(obj))[2]);
                        //troops.PeriodYear = Convert.ToString(((object[])(obj))[2]);
                        troops.SumofTroops = Convert.ToDecimal(((object[])(obj))[3]);
                        periodlist.Add(troops);
                    }
                    break;

                case "SECTOR":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.PeriodYear     = Convert.ToString(((object[])(obj))[1]);
                        troops.Period         = Convert.ToString(((object[])(obj))[2]);
                        troops.ContingentType = Convert.ToString(((object[])(obj))[3]);
                        troops.Sector         = Convert.ToString(((object[])(obj))[4]);
                        //troops.PeriodYear = Convert.ToString(((object[])(obj))[2]);
                        troops.SumofTroops = Convert.ToDecimal(((object[])(obj))[5]);
                        periodlist.Add(troops);
                    }
                    break;

                case "LOCATION":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.PeriodYear     = Convert.ToString(((object[])(obj))[1]);
                        troops.Period         = Convert.ToString(((object[])(obj))[2]);
                        troops.Sector         = Convert.ToString(((object[])(obj))[3]);
                        troops.Location       = Convert.ToString(((object[])(obj))[4]);
                        troops.Week           = Convert.ToInt64(((object[])(obj))[5]);
                        troops.SumofTroops    = Convert.ToDecimal(((object[])(obj))[6]);
                        troops.rank           = Convert.ToInt64(((object[])(obj))[7]);
                        periodlist.Add(troops);
                    }
                    break;

                case "NAME":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.PeriodYear     = Convert.ToString(((object[])(obj))[1]);
                        troops.Period         = Convert.ToString(((object[])(obj))[2]);
                        troops.Sector         = Convert.ToString(((object[])(obj))[3]);
                        troops.ContingentType = Convert.ToString(((object[])(obj))[4]);
                        troops.Location       = Convert.ToString(((object[])(obj))[5]);
                        troops.Week           = Convert.ToInt64(((object[])(obj))[6]);
                        troops.Name           = Convert.ToString(((object[])(obj))[7]);
                        troops.SumofTroops    = Convert.ToDecimal(((object[])(obj))[8]);
                        periodlist.Add(troops);
                    }
                    break;

                case "CONTINGENTTYPE":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.ContingentType = Convert.ToString(((object[])(obj))[1]);
                        //troops.PeriodYear = Convert.ToString(((object[])(obj))[2]);
                        troops.SumofTroops = Convert.ToDecimal(((object[])(obj))[2]);
                        periodlist.Add(troops);
                    }
                    break;

                case "WEEK":
                    foreach (var obj in list)
                    {
                        TroopsReport troops = new TroopsReport();
                        troops.TroopsReportId = Convert.ToInt64(((object[])(obj))[0]);
                        troops.Week           = Convert.ToInt64(((object[])(obj))[1]);
                        //troops.PeriodYear = Convert.ToString(((object[])(obj))[2]);
                        troops.SumofTroops = Convert.ToDecimal(((object[])(obj))[2]);
                        periodlist.Add(troops);
                    }
                    break;

                default:
                    break;
                }

                return(periodlist);
                // return PSF.ExecuteSql<samplestoredproceduure>(query);
            }
            catch (Exception)
            {
                throw;
            }
        }