示例#1
0
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var a = dataProvider.GetCustomerByLogon(txtUsername.Text);
                if (a.Customer.Count > 0)
                {
                    usernaemUnav.Visible = true;
                    return;
                }
                
                var customer = new CustomerDataSet();
                customer.Customer.AddCustomerRow(txtFName.Text, txtLName.Text, txtEmail.Text,txtPassword.Text, txtUsername.Text, 0, "", false);

                int result = dataProvider.AddCustomer(customer,int.Parse(cbSecurityQuestions.SelectedValue),txtAnswer.Text);

                if (result != -1)
                {
                    Message.Visible = true;
                    success.Visible = true;
                    registration.Visible = false;
                }
                else
                {
                    Message.Visible = false;
                    fail.Visible = true;
                    registration.Visible = false;
               }
            }
        }
示例#2
0
        public void SerializedTypedDataSet()
        {
            CustomerDataSet ds = new CustomerDataSet();

            ds.Customers.AddCustomersRow("234");

            string json = JsonConvert.SerializeObject(ds, Formatting.Indented);

            StringAssert.AreEqual(@"{
  ""Customers"": [
    {
      ""CustomerID"": ""234""
    }
  ]
}", json);

            CustomerDataSet ds1   = new CustomerDataSet();
            DataTable       table = ds1.Tables["Customers"];
            DataRow         row   = ds1.Tables["Customers"].NewRow();

            row["CustomerID"] = "234";

            table.Rows.Add(row);

            string json1 = JsonConvert.SerializeObject(ds1, Formatting.Indented);

            StringAssert.AreEqual(@"{
  ""Customers"": [
    {
      ""CustomerID"": ""234""
    }
  ]
}", json1);
        }
示例#3
0
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var a = dataProvider.GetCustomerByLogon(txtUsername.Text);
                if (a.Customer.Count > 0)
                {
                    usernaemUnav.Visible = true;
                    return;
                }

                var customer = new CustomerDataSet();
                customer.Customer.AddCustomerRow(txtFName.Text, txtLName.Text, txtEmail.Text, txtPassword.Text, txtUsername.Text, 0, "", false);

                int result = dataProvider.AddCustomer(customer, int.Parse(cbSecurityQuestions.SelectedValue), txtAnswer.Text);

                if (result != -1)
                {
                    Message.Visible      = true;
                    success.Visible      = true;
                    registration.Visible = false;
                }
                else
                {
                    Message.Visible      = false;
                    fail.Visible         = true;
                    registration.Visible = false;
                }
            }
        }
    public CustomerDataSet GetCustomerByUserName(string UserName)
    {
        SqlConnection   myConnection = new SqlConnection(m_strConnectionString);
        SqlCommand      myCommand    = new SqlCommand("usp_GetCustomerByUserName", myConnection);
        SqlDataAdapter  apdAdapter   = new SqlDataAdapter(myCommand);
        CustomerDataSet dasData;
        SqlParameter    parParameter;

        // Mark the Command as a SPROC
        myCommand.CommandType = CommandType.StoredProcedure;

        parParameter       = myCommand.Parameters.Add("@UserName", SqlDbType.NVarChar);
        parParameter.Value = UserName;

        apdAdapter.TableMappings.Add(
            "Table", "tbl_Customer");

        apdAdapter.TableMappings.Add(
            "Table1", "tbl_NetMembership");

        // Execute the command
        dasData = new CustomerDataSet();
        apdAdapter.Fill(dasData);

        return(dasData);
    }
        public override global::System.Data.DataSet Clone()
        {
            CustomerDataSet cln = ((CustomerDataSet)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            try
            {
                dsCustomer = new CustomerDataSet();
                customerTableAdapter daCustomer = new customerTableAdapter();
                daCustomer.Fill(dsCustomer.customer);


                if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page
                {
                    id = Convert.ToInt32(Request.Cookies["ID"].Value);
                }
                if (Request.Cookies["Action"] != null && Request.Cookies["Action"].Value == "Delete")
                {
                    pnlDeleteConfirm.Visible = true;
                    lblTitle.Text            = "Delete Customer";
                }
                else
                {
                    pnlDeleteConfirm.Visible = false;
                }
            }
            catch { return; }

            if (id != -1)
            {
                try
                {
                    DataRow customer = dsCustomer.customer.FindByID(id); // Find the related Record and fill the fields in the page with the data

                    if (customer != null)
                    {
                        this.txtID.Text      = customer.ItemArray[0].ToString();
                        this.txtFName.Text   = customer.ItemArray[1].ToString();
                        this.txtLName.Text   = customer.ItemArray[2].ToString();
                        this.txtPhone.Text   = customer.ItemArray[3].ToString();
                        this.txtAddress.Text = customer.ItemArray[4].ToString();
                        this.txtCity.Text    = customer.ItemArray[5].ToString();
                        this.txtPCode.Text   = customer.ItemArray[6].ToString();
                        this.txtEmail.Text   = customer.ItemArray[7].ToString();
                    }
                    else
                    {
                        lblStatus.Text = "Record doesn't exist";
                    }
                }
                catch
                {
                    lblStatus.Text = "Database Error";
                }
            }
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            CustomerDataSet ds = new CustomerDataSet();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            try
            {
                dsCustomer = new CustomerDataSet();
                customerTableAdapter daCustomer = new customerTableAdapter();
                daCustomer.Fill(dsCustomer.customer);
                rows = (Session["criteria"] != null) ? dsCustomer.customer.Select(Session["criteria"].ToString()) : dsCustomer.customer.Select();
                DisplayCustomer();
            }
            catch
            {
            }
            //data loaded successfully
        }
        private DataSet GetCustomersReport(string customerCode)
        {
            var customerDataSet   = new CustomerDataSet();
            var customerDataTable = customerDataSet.Tables["Customers"];
            var firmDataTable     = customerDataSet.Tables["FirmMaster"];

            _firmDataSetService.GetFirmDataTable(firmDataTable);
            var customerList = new List <Customer>();

            if (customerCode == "0")
            {
                customerList = _customerService.GetAllCustomers().ToList();
            }
            else
            {
                customerList.Add(_customerService.GetCustomerByCode(customerCode));
            }

            foreach (var cust in customerList)
            {
                var customerRow = customerDataTable.NewRow();

                customerRow["CustomerId"]   = cust.CustomersId;
                customerRow["CustomerCode"] = cust.CustomersCode;
                customerRow["CompanyName"]  = cust.CompanyName;
                customerRow["ContactName"]  = cust.ContactName;
                customerRow["Phone/Mobile"] = cust.Address.Phone;
                customerRow["Email"]        = cust.Properties.Email1;
                customerRow["Website"]      = cust.Properties.Website;
                customerRow["VATNumber"]    = cust.VATNumber;
                customerRow["Note"]         = cust.Properties.Note;

                customerDataTable.Rows.Add(customerRow);
            }
            return(customerDataSet);
        }
示例#10
0
        public CustomerDataSet GetCustomerByUserName(string UserName)
        {
            SqlConnection myConnection = new SqlConnection(m_strConnectionString);
            SqlCommand myCommand = new SqlCommand("usp_GetCustomerByUserName", myConnection);
            SqlDataAdapter apdAdapter = new SqlDataAdapter(myCommand);
            CustomerDataSet dasData;
            SqlParameter parParameter;

            // Mark the Command as a SPROC
            myCommand.CommandType = CommandType.StoredProcedure;

            parParameter = myCommand.Parameters.Add("@UserName", SqlDbType.NVarChar);
            parParameter.Value = UserName;

            apdAdapter.TableMappings.Add(
                "Table", "tbl_Customer");

            apdAdapter.TableMappings.Add(
                "Table1", "tbl_NetMembership");

            // Execute the command
            dasData = new CustomerDataSet();
            apdAdapter.Fill(dasData);

            return dasData;
        }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                CustomerDataSet ds = new CustomerDataSet();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "CustomerDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
    public void SerializedTypedDataSet()
    {
      CustomerDataSet ds = new CustomerDataSet();
      ds.Customers.AddCustomersRow("234");

      string json = JsonConvert.SerializeObject(ds, Formatting.Indented);

      Assert.AreEqual(@"{
  ""Customers"": [
    {
      ""CustomerID"": ""234""
    }
  ]
}", json);

      CustomerDataSet ds1 = new CustomerDataSet();
      DataTable table = ds1.Tables["Customers"];
      DataRow row = ds1.Tables["Customers"].NewRow();
      row["CustomerID"] = "234";

      table.Rows.Add(row);

      string json1 = JsonConvert.SerializeObject(ds1, Formatting.Indented);

      Assert.AreEqual(@"{
  ""Customers"": [
    {
      ""CustomerID"": ""234""
    }
  ]
}", json1);
    }
示例#13
0
        public int AddCustomer(CustomerDataSet customer,int security_question_id, string security_answer)
        {
            int newId = -1;
            
                try
                {
                    if (conn.State != ConnectionState.Open) { conn.Open(); }
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "spAddCustomer";

                    var p2 = new SqlParameter[5];
                    for (int i = 0; i < 5; i++)
                        p2[i] = new SqlParameter();

                    p2[0] = new SqlParameter("firstName", customer.Customer[0].FirstName);
                    p2[1] = new SqlParameter("lastName", customer.Customer[0].LastName);
                    p2[2] = new SqlParameter("email", customer.Customer[0].Email);
                    p2[3] = new SqlParameter("username",  customer.Customer[0].Username);
                    p2[4] = new SqlParameter("updatUser", 100);

                    cmd.Parameters.AddRange(p2);

                    newId = int.Parse(cmd.ExecuteScalar().ToString());
                    if (conn.State != ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                    UpdateUserSecurity(newId, customer.Customer[0].Hash, security_question_id,
                        security_answer);
               
                }
                catch (Exception ex)
                {
                    throw new OperationFailedException(ex.Message, ex);
                }
                finally
                {
                    if (conn.State != ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            
            return newId;
        }
示例#14
0
        public CustomerDataSet GetCustomerByLogon(string username)
        {
            var retDataset = new CustomerDataSet();

            try
            {
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "spGetCustomerByLogon";

                var p = new SqlParameter("username",username);
                
                cmd.Parameters.Add(p);

                SqlDataReader reader = cmd.ExecuteReader();
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        var user = retDataset.Customer.NewCustomerRow();
                        user.CustomerId = int.Parse(reader["CustomerId"].ToString());
                        user.FirstName = reader["FirstName"].ToString();
                        user.LastName = reader["LastName"].ToString();
                        user.Email = reader["Email"].ToString();
                        user.Username = reader["Username"].ToString();
                        user.Hash = reader["Hash"].ToString();
                        user.Status = reader["Status"].ToString();
                        user.StatusId = int.Parse(reader["StatusId"].ToString());
                        user.Active = bool.Parse(reader["Active"].ToString());

                        retDataset.Customer.AddCustomerRow(user);
                    }
                    reader.Close();
                }



            }
            catch (Exception ex)
            {
                throw new OperationFailedException(ex.Message, ex);
            }
            finally
            {
                if (conn.State != System.Data.ConnectionState.Closed)
                {
                    conn.Close();
                }
            }

            return retDataset;
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     CustomerDataSet ds = new CustomerDataSet();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }