Exemplo n.º 1
0
        public static Supplier Get(string guidOrEmail)
        {
            /*SupplierGet
                @id varchar(50)	--Id,Guid or Email
             */

            /*[Id], GroupId, Guid, Email, [Name], Gender,
             * CompanyName, Industry,Nature, Address, PhoneNumber,
             * ZIP, Website, FirstLogin, LastLogin,
             * LastIP, LoginTimes, Points, Status,
             *
             * FaxNumber, FoundedYear, ServiceAreas, Categories, Industries,CategoryLeadsNum,
             * AllowMatch,MatchMode,Balance
             */

            Supplier sp = null;

            SqlDataReader reader = null;
            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "SupplierGet",
                    new SqlParameter[] { Database.MakeInParam("@id", SqlDbType.VarChar, 50, guidOrEmail) });

                if (reader.Read())
                {
                    sp = new Supplier();
                    sp.id = reader.GetInt32(0);
                    sp.groupId = reader.GetInt32(1);
                    sp.guid = reader.GetString(2);
                    sp.email = reader.GetString(3);
                    sp.name = reader.GetString(4);
                    sp.gender = Convert.ToChar(reader.GetString(5));
                    sp.companyName = reader.GetString(6);
                    sp.industry = reader.GetString(7);
                    sp.nature = reader.GetString(8);
                    sp.address = reader.GetString(9);
                    sp.phoneNumber = reader.GetString(10);
                    sp.zip = reader.GetString(11);
                    sp.website = reader.GetString(12);
                    sp.regDate = reader.GetDateTime(13);
                    sp.firstLogin = reader.GetDateTime(14);
                    sp.lastLogin = reader.GetDateTime(15);
                    sp.lastIP = reader.GetString(16);
                    sp.loginTimes = reader.GetInt32(17);
                    sp.points = reader.GetInt32(18);
                    sp.status = (CompanyStatus)(reader.GetInt16(19));

                    sp.faxNumber = reader.GetString(20);
                    sp.foundedYear = reader.GetInt16(21);

                    sp.serviceAreas=reader.IsDBNull(22)?"":reader.GetString(22);
                    sp.categories = reader.IsDBNull(23) ? "" : reader.GetString(23);
                    sp.industries = reader.IsDBNull(24) ? "" : reader.GetString(24);
                    sp.categoryLeadsNums = reader.IsDBNull(25) ? "" : reader.GetString(25);
                    sp.allowMatch = reader.GetString(26) == "1";
                    sp.matchMode = reader.GetString(27) == "A" ? SupplierMatchMode.Auto : SupplierMatchMode.Manual;
                    sp.balance = Convert.ToSingle(reader.GetValue(28));
                }
                reader.Close();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            if (sp != null)
            {
                Group gp = Group.Get(sp.groupId);
                if (gp != null)
                {
                    sp.rights = SupplierRights.ConvertFromString(gp.Rights) as SupplierRights;
                }
            }

            return sp;
        }
Exemplo n.º 2
0
        /// <summary>
        /// ��Ӧ��ע��
        /// </summary>
        private void DoRegister()
        {
            if (Request.Form["email"] != null &&
                Request.Form["pwd"] != null &&
                Request.Form["confirmPwd"] != null &&
                Request.Form["uname"] != null &&
                Request.Form["ugender"] != null &&
                Request.Form["comName"] != null &&
                //Request.Form["comIndustry"]!=null &&
                Request.Form["comNature"] != null &&
                Request.Form["comFounded"] != null &&
                Request.Form["comLocation"] != null &&
                Request.Form["comAddress"] != null &&
                Request.Form["comPhone"] != null &&
                Request.Form["comFax"] != null &&
                Request.Form["comWebsite"] != null &&
                Request.Form["category"] != null)
            {
                string email = Request.Form["email"].Trim();
                if (!Util.IsValidEmail(email))
                {
                    Response.Write("showErrInputMsg(\"Email\",\"�ʼ���ַ��ʽ����\");");
                    return;
                }

                if (Company.IsExistsEmail(email))
                {
                    Response.Write("showErrInputMsg(\"Email\",\"�ʼ���ַ�Ѿ���ʹ�ã�\");");
                    return;
                }

                string pwd = Request.Form["pwd"].Trim();
                string uname = Request.Form["uname"].Trim();
                string gender = Request.Form["ugender"].Trim();
                string comName = Request.Form["comName"].Trim();
                string comIndus = "000000";//Request.Form["comIndustry"].Trim();
                string comNature = Request.Form["comNature"].Trim();
                string comFounded = Request.Form["comFounded"].Trim();
                string location = Request.Form["comLocation"].Trim();
                string addr = Request.Form["comAddress"].Trim();
                string phone = Request.Form["comPhone"].Trim();
                string fax = Request.Form["comFax"];
                string web = Request.Form["comWebsite"];

                if (String.IsNullOrEmpty(uname))
                {
                    Response.Write("showErrInputMsg(\"Uname\",\"������������\");");
                    return;
                }

                if (String.IsNullOrEmpty(comName))
                {
                    Response.Write("showErrInputMsg(\"ComName\",\"��ҵ���Ʋ���Ϊ�գ�\");");
                    return;
                }

                try
                {
                    int fy = Convert.ToInt16(comFounded);
                    if (fy < 1800 || fy > DateTime.Now.Year)
                    {
                        Response.Write("showErrInputMsg(\"ComFounded\",\"��ҵ������ݱ������1800-" + DateTime.Now.Year.ToString() + "֮�䣡\");");
                        return;
                    }
                }
                catch
                {
                    Response.Write("showErrInputMsg(\"ComName\",\"��ҵ������ݱ���ʹ��4λ�������룡\");");
                    return;
                }

                if (String.IsNullOrEmpty(addr))
                {
                    Response.Write("showErrInputMsg(\"ComName\",\"��ҵ��ϸ��ַ����Ϊ�գ�\");");
                    return;
                }

                if (String.IsNullOrEmpty(phone))
                {
                    Response.Write("showErrInputMsg(\"ComName\",\"��ҵ�绰���벻��Ϊ�գ�\");");
                    return;
                }

                Supplier sp = new Supplier();
                sp.InviteUserId = base.InviteUserId;
                sp.Email = email;
                sp.Name = uname;
                sp.Gender = gender.ToCharArray(0, 1)[0];
                sp.Password = pwd;
                sp.CompanyName = comName;
                sp.Nature = comNature;
                sp.Industry = comIndus;
                sp.FoundedYear = Convert.ToInt16(comFounded);
                sp.ZIP = location;
                sp.Address = addr;
                sp.PhoneNumber = phone;
                sp.FaxNumber = fax;
                sp.Website = web.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? web : "http://" + web;
                sp.RegDate = DateTime.Now;

                if (sp.Register())
                {
                    Cookies.WriteCookie("SP_REG_TEMP","",360,"id="+sp.Id.ToString()+"&guid=" + sp.Guid + "&categories=" + Request.Form["category"].Trim() + "&email=" + email + "&pwd=" + pwd + "&comname=" + comName + "&name=" + uname + "&gender=" + gender);
                    Response.Write("true");
                }
                else
                {
                    Response.Write("setMessage(\"ע������г��ִ������������Ƿ����Ҫ��\",false);");
                }
            }
        }