Exemple #1
0
 public string ShowMatInText(string strCondition)
 {
     string[] strArr = strCondition.Split(':');
     System.Collections.ArrayList mass = new System.Collections.ArrayList();
     System.Collections.ArrayList key1 = new System.Collections.ArrayList();
     System.Collections.ArrayList key2 = new System.Collections.ArrayList();
     System.Collections.ArrayList key3 = new System.Collections.ArrayList();
     using (SqlText sql = new SqlText(String.Format("select m.MassPartsIDFlag, m.ExpansionKey1, m.ExpansionKey2, m.ExpansionKey3 from MaterialNumber as m join Customer as c on m.ShiptoParty = c.Code where c.PlantCode = '{1}' and shiptoParty like '{0}%' and m.customerItemNumber = '{2}'", strArr[0], strArr[1], strArr[2])))
     {
         System.Data.Common.DbDataReader readerSender = sql.ExecuteReader();
         while (readerSender.Read())
         {
             mass.Add(readerSender["MassPartsIDFlag"].ToString());
             key1.Add(readerSender["ExpansionKey1"].ToString());
             key2.Add(readerSender["ExpansionKey2"].ToString());
             key3.Add(readerSender["ExpansionKey3"].ToString());
         }
         readerSender.Close();
         readerSender.Dispose();
     }
     MN[] l = new MN[mass.Count];
     for (int i = 0; i <= mass.Count - 1; i++)
     {
         l[i] = new MN();
         l[i].MassPartsIDFlag = mass[i].ToString();
         l[i].ExpansionKey1   = key1[i].ToString();
         l[i].ExpansionKey2   = key2[i].ToString();
         l[i].ExpansionKey3   = key3[i].ToString();
     }
     return(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(l));
 }
    /// <summary>
    /// Get any manually submitted jobs.  These are on the BatchJobQueue table.
    /// They are deleted from the table once they have been selected for processing.
    /// </summary>
    /// <returns></returns>
    private static List <JobRequest> AnyManualJobsRequired()
    {
        List <JobRequest> jobs = new List <JobRequest>();

        // safely get jobs that have been manually submitted  (exclude jobs prefixed with ABLE these are processed by the ABLE Commerce site.
        using (Redi.Utility.SqlText select = new SqlText(
                   "Select DBID, RequestName, RequestedDateTimeUtc, Submitted, RequestData " +
                   "From ALL_BatchJobQueue " +
                   "Where Submitted = 0 AND DueDateTimeUtc <= @DueDateTimeUtc AND RequestName Like'ABLE%' "))
        {
            select.AddParameter("@DueDateTimeUtc", DateTime.UtcNow);
            DbDataReader myReader = select.ExecuteReader();
            while (myReader.Read())
            {
                JobRequest job = new JobRequest();
                job.RequestDBID = myReader.GetInt64(0);
                job.Name        = myReader.GetString(1);
                job.RequestedAt = myReader.GetDateTime(2);
                job.Submitted   = myReader.GetBoolean(3);
                job.RequestData = myReader.GetString(4).Trim('?');

                jobs.Add(job);
            }
        }
        return(jobs);
    }
Exemple #3
0
 public string cbPlantCode(string strCondition)
 {
     System.Collections.ArrayList receiverList = new System.Collections.ArrayList();
     using (SqlText sql = new SqlText(String.Format("select distinct(PlantCode) from Customer where Code like '{0}%' and PlantCode is not null", strCondition)))
     {
         System.Data.Common.DbDataReader readerSender = sql.ExecuteReader();
         while (readerSender.Read())
         {
             receiverList.Add(readerSender["PlantCode"].ToString());
         }
         readerSender.Close();
         readerSender.Dispose();
     }
     MN[] l = new MN[receiverList.Count];
     for (int i = 0; i <= receiverList.Count - 1; i++)
     {
         l[i]         = new MN();
         l[i].strItem = receiverList[i].ToString();
     }
     return(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(l));
 }
Exemple #4
0
 public string cbMatCode(string strCondition)
 {
     string[] strArr = strCondition.Split(':');
     System.Collections.ArrayList receiverList = new System.Collections.ArrayList();
     using (SqlText sql = new SqlText(String.Format("select m.customerItemNumber from MaterialNumber as m join Customer as c on m.ShiptoParty = c.Code where c.PlantCode = '{1}' and shiptoParty like '{0}%'", strArr[0], strArr[1])))
     {
         System.Data.Common.DbDataReader readerSender = sql.ExecuteReader();
         while (readerSender.Read())
         {
             receiverList.Add(readerSender["customerItemNumber"].ToString());
         }
         readerSender.Close();
         readerSender.Dispose();
     }
     MN[] l = new MN[receiverList.Count];
     for (int i = 0; i <= receiverList.Count - 1; i++)
     {
         l[i]         = new MN();
         l[i].strItem = receiverList[i].ToString();
     }
     return(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(l));
 }
    private static void GetCompanyAndClient(Order order, out Int32?companyId, out Int32?clientId)
    {
        companyId = null;
        clientId  = null;

        // See if the client exists
        using (SqlText select = new SqlText(
                   "Select ClientId, FullName, FirstName, LastName, EmailAddress, [ALL_Company].CompanyId, [ALL_Company].CompanyName " +
                   "From [ALL_Client] " +
                   "Left Outer Join [ALL_Company] ON [ALL_Company].CompanyId = [ALL_Client].CompanyId " +
                   "Where EmailAddress = @EmailAddress AND [ALL_Client].Deleted=0 ", crmConnectionStringName))
        {
            select.AddParameter("@EmailAddress", order.BillToEmail.Trim());
            DbDataReader myReader = select.ExecuteReader();
            while (myReader.Read())
            {
                Int32  wkClientId = myReader.GetInt32(0);
                string wkName     = myReader.GetString(1);
                //string wkFirstName = myReader.GetString(2);
                //string wkLastname = myReader.GetString(3);
                string wkEmail     = myReader.GetString(4);
                Int32? wkCompanyId = null;
                if (!myReader.IsDBNull(5))
                {
                    wkCompanyId = myReader.GetInt32(5);
                }
                string wkCompanyName = "";
                if (!myReader.IsDBNull(6))
                {
                    wkCompanyName = myReader.GetString(6);
                }

                clientId  = wkClientId;
                companyId = wkCompanyId;
            }
        }

        if (clientId != null)
        {
            // Found a record so exit.
            return;
        }

        if (!string.IsNullOrEmpty(order.BillToCompany) && companyId == null && clientId == null)
        {
            // See if the company exists
            using (SqlText select = new SqlText(
                       "Select CompanyId, CompanyName " +
                       "From [ALL_Company] " +
                       "Where CompanyName = @CompanyName AND Deleted=0 AND DepartmentName is null ", crmConnectionStringName))
            {
                select.AddParameter("@CompanyName", order.BillToCompany.Trim());
                DbDataReader myReader = select.ExecuteReader();
                while (myReader.Read())
                {
                    companyId = myReader.GetInt32(0);
                }
            }

            if (companyId == null)
            {
                // Not found so create a new company record.
                using (Redi.Utility.SqlText insert = new Redi.Utility.SqlText(
                           "Insert Into ALL_Company (CompanyName, CreatedOn, CreatedByName) " +
                           "Values (@CompanyName, @CreatedOn, @CreatedByName) " +
                           "SELECT SCOPE_IDENTITY(); ", crmConnectionStringName))
                {
                    insert.AddParameter("@CompanyName", order.BillToCompany.Trim());
                    insert.AddParameter("@CreatedOn", GetCurrentStandardTime());
                    insert.AddParameter("@CreatedByName", createdBy);

                    companyId = Convert.ToInt32(insert.ExecuteScalar());
                }
            }
        }

        string wkMobile   = "";
        string wkPhone    = "";
        string wkFax      = "";
        string wkFullName = "";

        if (!string.IsNullOrEmpty(order.BillToFirstName))
        {
            wkFullName = order.BillToFirstName.Trim() + ' ';
        }
        if (!string.IsNullOrEmpty(order.BillToLastName))
        {
            wkFullName = wkFullName + order.BillToLastName.Trim();
        }

        if (!string.IsNullOrEmpty(order.BillToPhone))
        {
            if (order.BillToPhone.Length > 2 && order.BillToPhone.Substring(0, 2) == "04")
            {
                wkMobile = order.BillToPhone;
            }
            else
            {
                wkPhone = order.BillToPhone;
            }
        }

        if (!string.IsNullOrEmpty(order.BillToFax))
        {
            wkFax = order.BillToFax;
        }

        // Not an existing client so create a new record.
        using (Redi.Utility.SqlText insert = new Redi.Utility.SqlText(
                   "Insert Into ALL_Client (FullName, FirstName, LastName, Phone, Fax, MobilePhone, CreatedOn, CreatedByName, EmailAddress, CompanyId ) " +
                   "Values (@FullName, @FirstName, @LastName, @Phone, @Fax, @MobilePhone, @CreatedOn, @CreatedByName, @EmailAddress, @CompanyId) " +
                   "SELECT SCOPE_IDENTITY(); ", crmConnectionStringName))
        {
            insert.AddParameter("@FullName", wkFullName);
            insert.AddParameter("@FirstName", order.BillToFirstName);
            insert.AddParameter("@LastName", order.BillToLastName);
            insert.AddParameter("@Phone", wkPhone);
            insert.AddParameter("@Fax", wkFax);
            insert.AddParameter("@MobilePhone", wkMobile);
            if (companyId != null)
            {
                insert.AddParameter("@CompanyId", companyId);
            }
            else
            {
                insert.AddParameter("@CompanyId", System.Data.SqlTypes.SqlInt32.Null);
            }
            insert.AddParameter("@CreatedOn", GetCurrentStandardTime());
            insert.AddParameter("@CreatedByName", createdBy);
            insert.AddParameter("@EmailAddress", order.BillToEmail);

            clientId = Convert.ToInt32(insert.ExecuteScalar());
        }
    }
        public void r101Implementation(SystemMenuModel instance)
        {
            System.Collections.ArrayList mass = new System.Collections.ArrayList();
            System.Collections.ArrayList key1 = new System.Collections.ArrayList();
            System.Collections.ArrayList key2 = new System.Collections.ArrayList();
            System.Collections.ArrayList key3 = new System.Collections.ArrayList();
            using (SqlText sql = new SqlText(String.Format("SELECT PageName, PageDescription, PageRoles, PageUrl FROM SystemMenu")))
            {
                System.Data.Common.DbDataReader readerSender = sql.ExecuteReader();
                while (readerSender.Read())
                {
                    //Web.Sitemap
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(HttpContext.Current.Server.MapPath("~/Web.sitemap"));
                    XmlNodeList elementList = xmlDoc.GetElementsByTagName("siteMapNode");
                    foreach (XmlNode node in elementList)
                    {
                        if (node.Attributes["title"].Value == readerSender["PageName"].ToString())
                        {
                            XmlAttribute description = xmlDoc.CreateAttribute("description");
                            node.Attributes.Append(description);
                            node.Attributes["description"].Value = readerSender["PageDescription"].ToString();

                            XmlAttribute url = xmlDoc.CreateAttribute("url");
                            node.Attributes.Append(url);
                            node.Attributes["url"].Value = readerSender["PageUrl"].ToString();

                            XmlAttribute roles = xmlDoc.CreateAttribute("roles");
                            node.Attributes.Append(roles);
                            node.Attributes["roles"].Value = readerSender["PageRoles"].ToString();

                            xmlDoc.Save(HttpContext.Current.Server.MapPath("~/Web.sitemap"));
                        }
                    }
                    //Web.config
                    xmlDoc = new XmlDocument();
                    xmlDoc.Load(HttpContext.Current.Server.MapPath("~/web.config"));



                    bool pathXml = true;
                    elementList = xmlDoc.GetElementsByTagName("location");
                    foreach (XmlNode node in elementList)
                    {
                        if (node.Attributes["path"].Value == readerSender["PageUrl"].ToString().Substring(2))
                        {
                            //node.InnerXml
                            pathXml = false;
                            string rp = "<system.web><authorization><allow roles=\"" + readerSender["PageRoles"].ToString() + "\" /><deny users=\" * \" /></authorization></system.web>";
                            node.InnerXml = rp;
                            xmlDoc.Save(HttpContext.Current.Server.MapPath("~/web.config"));
                        }
                    }
                    if (pathXml && readerSender["PageRoles"].ToString() != "*")
                    {
                        XmlElement locationNode = xmlDoc.CreateElement("location");
                        locationNode.SetAttribute("path", readerSender["PageUrl"].ToString().Substring(2));
                        XmlNodeList elementListConfig = xmlDoc.GetElementsByTagName("configuration");
                        XmlElement  swNode            = xmlDoc.CreateElement("system.web");
                        locationNode.AppendChild(swNode);
                        XmlElement authorizationNode = xmlDoc.CreateElement("authorization");
                        swNode.AppendChild(authorizationNode);
                        XmlElement allowNode = xmlDoc.CreateElement("allow");
                        allowNode.SetAttribute("roles", readerSender["PageRoles"].ToString());
                        authorizationNode.AppendChild(allowNode);
                        XmlElement denyNode = xmlDoc.CreateElement("deny");
                        denyNode.SetAttribute("users", " * ");
                        authorizationNode.AppendChild(denyNode);

                        foreach (XmlNode nodeConfig in elementListConfig)
                        {
                            nodeConfig.AppendChild(locationNode);
                            xmlDoc.Save(HttpContext.Current.Server.MapPath("~/web.config"));
                        }
                    }
                }
                readerSender.Close();
                readerSender.Dispose();
            }
        }