Beispiel #1
0
        public static bool AddNewCustomer(BusinessLogic.Customer NewCustomer, out string ErrorMessage)
        {
            bool Result = true;

            ErrorMessage = string.Empty;
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);
            DataRow NewRow = AppData.Table_Customers.NewRow();

            NewRow["CustomerLogin"]    = NewCustomer.Login;
            NewRow["CustomerPassword"] = NewCustomer.Password;
            NewRow["CustomerTypeId"]   = NewCustomer.CurrentType.Id;
            try
            {
                AppData.Table_Customers.Rows.Add(NewRow);
                AppData.WriteXml(DataPath);
            }
            catch (System.Exception CurrentException)
            {
                ErrorMessage = CurrentException.Message;
                Result       = false;
            }
            AppData.Dispose();
            return(Result);
        }
Beispiel #2
0
        public static BusinessLogic.Customer GetCustomerById(int Id)
        {
            BusinessLogic.Customer Result  = null;
            AppDataSet             AppData = new AppDataSet();

            AppData.ReadXml(DataPath);

            DataRow[] ResultCustomersRows = AppData.Table_Customers.Select("CustomerId=" + Id.ToString());
            if (ResultCustomersRows.Length > 0)
            {
                Result          = new BusinessLogic.Customer();
                Result.Id       = Id;
                Result.Login    = ResultCustomersRows[0]["CustomerLogin"].ToString();
                Result.Password = ResultCustomersRows[0]["CustomerPassword"].ToString();
                string CustomerTypeId = ResultCustomersRows[0]["CustomerTypeId"].ToString();

                DataRow[] ResultCustomerTypeRows = AppData.Table_Customers.Select("CustomerTypeId=" + CustomerTypeId);
                if (ResultCustomerTypeRows.Length == 0)
                {
                    AppData.Dispose();
                    return(null);
                }

                Result.CurrentType    = new BusinessLogic.CustomerType();
                Result.CurrentType.Id = Convert.ToInt32(ResultCustomerTypeRows[0]["CustomerTypeId"]);
                //Result.CurrentType.Name = ResultCustomerTypeRows[0]["CustomerTypeName"].ToString();
            }
            return(Result);
        }
Beispiel #3
0
        public static BusinessLogic.Customer GetCustomerByLoginAndPassword(string Login, string Password)
        {
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);

            List <BusinessLogic.CustomerType> Types = new List <BusinessLogic.CustomerType>();

            for (int i = 0; i < AppData.Table_CustomerType.Rows.Count; ++i)
            {
                BusinessLogic.CustomerType CurrentType = new BusinessLogic.CustomerType();
                CurrentType.Id   = Convert.ToInt32(AppData.Table_CustomerType.Rows[i]["CustomerTypeId"]);
                CurrentType.Name = AppData.Table_CustomerType.Rows[i]["CustomerTypeName"].ToString();
                Types.Add(CurrentType);
            }

            DataRow[] ResultRows = AppData.Table_Customers.Select("CustomerLogin='******' AND CustomerPassword='******'");
            if (ResultRows.Length == 0)
            {
                AppData.Dispose();
                return(null);
            }

            BusinessLogic.Customer Result = new BusinessLogic.Customer();
            Result.Id          = Convert.ToInt32(ResultRows[0]["CustomerId"]);
            Result.Login       = Login;
            Result.Password    = Password;
            Result.CurrentType = Types.Find(temp => temp.Id == Convert.ToInt32(ResultRows[0]["CustomerTypeId"]));
            AppData.Dispose();
            return(Result);
        }
Beispiel #4
0
        public static List <BusinessLogic.Customer> GetCustomersList()
        {
            List <BusinessLogic.Customer> Result = new List <BusinessLogic.Customer>();
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);

            List <BusinessLogic.CustomerType> Types = new List <BusinessLogic.CustomerType>();

            for (int i = 0; i < AppData.Table_CustomerType.Rows.Count; ++i)
            {
                BusinessLogic.CustomerType CurrentType = new BusinessLogic.CustomerType();
                CurrentType.Id   = Convert.ToInt32(AppData.Table_CustomerType.Rows[i]["CustomerTypeId"]);
                CurrentType.Name = AppData.Table_CustomerType.Rows[i]["CustomerTypeName"].ToString();
                Types.Add(CurrentType);
            }

            for (int i = 0; i < AppData.Table_Customers.Rows.Count; ++i)
            {
                BusinessLogic.Customer NewCustomer = new BusinessLogic.Customer();
                NewCustomer.Id          = Convert.ToInt32(AppData.Table_Customers.Rows[i]["CustomerId"]);
                NewCustomer.Login       = AppData.Table_Customers.Rows[i]["CustomerLogin"].ToString();
                NewCustomer.Password    = AppData.Table_Customers.Rows[i]["CustomerPassword"].ToString();
                NewCustomer.CurrentType = Types.Find(temp => temp.Id == Convert.ToInt32(AppData.Table_Customers.Rows[i]["CustomerTypeId"]));
                Result.Add(NewCustomer);
            }
            return(Result);
        }
Beispiel #5
0
        public static bool UpdateCustomer(BusinessLogic.Customer EditedCustomer, out string ErrorMessage)
        {
            ErrorMessage = string.Empty;
            bool Result = true;

            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);

            DataRow[] ResultCustomerRows = AppData.Table_Customers.Select("CustomerId = " + EditedCustomer.Id.ToString());
            if (ResultCustomerRows.Length > 0)
            {
                try
                {
                    ResultCustomerRows[0]["CustomerLogin"]    = EditedCustomer.Login;
                    ResultCustomerRows[0]["CustomerPassword"] = EditedCustomer.Password;
                    ResultCustomerRows[0]["CustomerTypeId"]   = EditedCustomer.CurrentType.Id;
                    AppData.WriteXml(DataPath);
                }
                catch (System.Exception ex)
                {
                    Result       = false;
                    ErrorMessage = ex.Message;
                    AppData.Dispose();
                }
            }
            AppData.Dispose();
            return(Result);
        }
Beispiel #6
0
        public override global::System.Data.DataSet Clone()
        {
            AppDataSet cln = ((AppDataSet)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Beispiel #7
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            AppDataSet ds = new AppDataSet();

            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);
        }
Beispiel #8
0
        public static List <BusinessLogic.CustomerType> GetCustomerTypeList()
        {
            AppDataSet AppData = new AppDataSet();

            AppData.ReadXml(DataPath);
            List <BusinessLogic.CustomerType> Result = new List <BusinessLogic.CustomerType>();

            for (int i = 0; i < AppData.Table_CustomerType.Rows.Count; ++i)
            {
                BusinessLogic.CustomerType CurrentType = new BusinessLogic.CustomerType();
                CurrentType.Id   = Convert.ToInt32(AppData.Table_CustomerType.Rows[i]["CustomerTypeId"]);
                CurrentType.Name = AppData.Table_CustomerType.Rows[i]["CustomerTypeName"].ToString();
                Result.Add(CurrentType);
            }
            AppData.Dispose();
            return(Result);
        }
Beispiel #9
0
        static DataManager()
        {
            AppDataSet AppData = new AppDataSet();

            if (!File.Exists(DataPath))
            {
                DataRow NewRow = AppData.Table_CustomerType.NewRow();
                NewRow["CustomerTypeName"] = "Administrator";
                AppData.Table_CustomerType.Rows.Add(NewRow);
                NewRow = AppData.Table_CustomerType.NewRow();
                NewRow["CustomerTypeName"] = "User";
                AppData.Table_CustomerType.Rows.Add(NewRow);

                NewRow = AppData.Table_Customers.NewRow();
                NewRow["CustomerTypeId"]   = 1;
                NewRow["CustomerLogin"]    = "******";
                NewRow["CustomerPassword"] = "******";
                AppData.Table_Customers.Rows.Add(NewRow);

                AppData.WriteXml(DataPath);
                AppData.Dispose();
            }
        }
Beispiel #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Customer CurrentCustomer = Customer.GetCustomerByLoginAndPassword
                                       (
                TextBoxLogin.Text,
                TextBoxPassword.Text
                                       );
            if (CurrentCustomer != null)
            {
                CurrentCustomer.SaveToSession();
                switch (CurrentCustomer.CurrentType.Name)
                {
                case "Administrator":
                    Response.Redirect("AdministratorPage.aspx");
                    //Server.Transfer("AdministratorPage.aspx");
                    break;

                case "User":
                    Response.Redirect("UserPage.aspx");
                    //Server.Transfer("UserPage.aspx");
                    break;
                }
            }
            else
            {
                LiteralMessage.Text = "Login or Password is not correctly";
            }
        }
        else
        {
            AppDataSet AppData = new AppDataSet();
            AppData.WriteXmlSchema(System.Configuration.ConfigurationManager.AppSettings["DataShemaPath"].ToString());
        }
    }
Beispiel #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="row">Field Types row in application dataset.</param>
 public FieldType(AppDataSet.FieldTypesRow row)
 {
     inner = row;
 }
 public Converter(AppDataSet dataSet)
 {
     this.dataSet = dataSet;
 }
            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();
                AppDataSet ds = new AppDataSet();

                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 = "FileDataTable";
                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);
            }
Beispiel #14
0
 public EditDieAssignmentConverter(AppDataSet dataSet)
 {
     this.dataSet = dataSet;
 }