private async void lstName_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                ContactsTable item = (ContactsTable)e.Item;

                NameSearch.Text   = item.FileAs;
                lstName.IsVisible = false;

                var getCode     = Constants.conn.QueryAsync <ContactsTable>("SELECT * FROM tblContacts WHERE FileAs=?", NameSearch.Text);
                var resultCount = getCode.Result.Count;

                if (resultCount > 0)
                {
                    for (int i = 0; i < resultCount; i++)
                    {
                        var result = getCode.Result[i];
                        entContact.Text = result.ContactID.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                await DisplayAlert("Application Error", "Error:\n\n" + ex.Message.ToString() + "\n\n Please contact your administrator", "Ok");
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            db = new NotebookDBDataContext();

            if (Request.Cookies["Token"] == null || Request.Cookies["Token"].Value == null || (from t in db.Token where t.Id.ToString() == Request.Cookies["Token"].Value select t).Count() == 0)
            {
                Response.Redirect("/login.aspx");
            }
            else
            {
                userid = (from t in db.Token where t.Id.ToString() == Request.Cookies["Token"].Value select t).ToArray()[0].UserId;

                int id;

                if (Request.Params["method"] == "delete" && Request.Params["id"] != null && int.TryParse(Request.Params["id"], out id))
                {
                    Contact[] contact = (from c in db.Contact where c.Id == id where c.UserId == userid select c).ToArray();
                    if (contact.Length != 0)
                    {
                        db.Contact.DeleteOnSubmit(contact[0]);
                    }
                    db.SubmitChanges();
                }

                ContactsTable.DataSource = (from c in db.Contact where c.UserId == userid select c).ToArray();
                ContactsTable.DataBind();
            }

            Unload += Contacts_Unload;
        }
        public IHttpActionResult PutContactsTable(int id, ContactsTable contactsTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != contactsTable.ContactsId)
            {
                return(BadRequest());
            }

            db.Entry(contactsTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactsTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)//計算價錢
        {
            string start, end;
            var    ticketFare = new ContactsTable();

            start = startComboBox.SelectedItem.ToString();
            end   = endComboBox.SelectedItem.ToString();
            if (toSouthRadioButton.Checked)
            {
                ticketFare = list.FirstOrDefault((x) => x.StartStation == start && x.EndStation == end);
            }
            else
            {
                ticketFare = list.FirstOrDefault((x) => x.StartStation == end && x.EndStation == start);
            }

            if (checkBox1.Checked == true && checkBox2.Checked == true)
            {
                label4.Text = Math.Ceiling(ticketFare.Fare * 2 * 0.81).ToString();
            }
            else if (checkBox1.Checked == true)
            {
                label4.Text = Math.Ceiling(ticketFare.Fare * 2 * 0.9).ToString();
            }
            else if (checkBox2.Checked == true)
            {
                label4.Text = Math.Ceiling(ticketFare.Fare * 0.9).ToString();
            }
            else
            {
                label4.Text = ticketFare.Fare.ToString();
            }
        }
Exemple #5
0
        public void Sales()
        {
            ContactsTable data = new ContactsTable();

            {
                try
                {
                    data.SaleTable.Add(new SaleTable()
                    {
                        Sales = "Bill", Pen = 33, Pencil = 32, Eraser = 56, Ruler = 45, Whiteout = 33
                    });
                    data.SaleTable.Add(new SaleTable()
                    {
                        Sales = "John", Pen = 77, Pencil = 33, Eraser = 68, Ruler = 45, Whiteout = 23
                    });
                    data.SaleTable.Add(new SaleTable()
                    {
                        Sales = "David", Pen = 43, Pencil = 55, Eraser = 43, Ruler = 67, Whiteout = 65
                    });

                    data.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                dataGridView1.DataSource = data.SaleTable.ToList();
            }
        }
Exemple #6
0
        public JavaScriptResult UpdateContact(ContactsTable contactTable)
        {
            _modelUser.ContactUpdate(contactTable.ContactContent);

            string rtrn = "$('#divInformation').html('<img src=/Areas/Administrator/Images/ajax-loader.gif class=loaderGif></img>'); window.location='/administrator/contact'";

            return(JavaScript(rtrn));
        }
Exemple #7
0
        public int AddContact(ContactModel contact)
        {
            SqlConnectionDB dataBase = new SqlConnectionDB("SqlConnection");

            ContactsTable tableData = new ContactsTable();

            Mapper.Map(contact, tableData);

            return((int)dataBase.Insert(tableName: "dbo.ContactsTable", primaryKeyName: "Id", autoIncrement: false, poco: tableData));
        }
        public IHttpActionResult GetContactsTable(int id)
        {
            ContactsTable contactsTable = db.ContactsTables.Find(id);

            if (contactsTable == null)
            {
                return(NotFound());
            }

            return(Ok(contactsTable));
        }
        public IHttpActionResult PostContactsTable(ContactsTable contactsTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ContactsTables.Add(contactsTable);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = contactsTable.ContactsId }, contactsTable));
        }
        public IHttpActionResult PostContactsTable(ContactsTable contactsTable)
        {
            try
            {
                db.ContactsTables.Add(contactsTable);
                db.SaveChanges();

                return(CreatedAtRoute("DefaultApi", new { id = contactsTable.ContactsId }, contactsTable));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
        public IHttpActionResult DeleteContactsTable(int id)
        {
            ContactsTable contactsTable = db.ContactsTables.Find(id);

            if (contactsTable == null)
            {
                return(NotFound());
            }

            db.ContactsTables.Remove(contactsTable);
            db.SaveChanges();

            return(Ok(contactsTable));
        }
Exemple #12
0
        public ContactModel GetContact(int Id)
        {
            SqlConnectionDB dataBase = new SqlConnectionDB("SqlConnection");

            ContactModel contact = new ContactModel();

            ContactsTable contactTable = new ContactsTable();

            contactTable = dataBase.Single <ContactsTable>("WHERE Id = @0", Id);

            Mapper.Map(contactTable, contact);

            return(contact);
        }
 private void ContactsTable_OnItemClick(object sender, ItemClickEventArgs e)
 {
     if (e.ClickedItem != null)
     {
         EditCard edit = EditCardPanel;
         edit.DeleteVisible(true);
         var data = e.ClickedItem as ContactObject;
         if (data != null)
         {
             edit.Contact        = data;
             edit.AttachedFlyout = EditCardFlyout;
             DependencyObject container = ContactsTable.ContainerFromItem(data);
             EditCardFlyout.ShowAt(container as FrameworkElement);
         }
     }
 }
        private async void lstProspect_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                var appdate = Preferences.Get("appdatetime", String.Empty, "private_prefs");

                if (string.IsNullOrEmpty(appdate))
                {
                    Preferences.Set("appdatetime", DateTime.Now.ToString(), "private_prefs");
                }
                else
                {
                    try
                    {
                        if (DateTime.Now >= DateTime.Parse(Preferences.Get("appdatetime", String.Empty, "private_prefs")))
                        {
                            Preferences.Set("appdatetime", DateTime.Now.ToString(), "private_prefs");

                            ContactsTable item = (ContactsTable)e.Item;

                            await Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new ProspectRetailerDetails(item))
                            {
                                BarBackgroundColor = Color.FromHex("#f1c40f")
                            });
                        }
                        else
                        {
                            await DisplayAlert("Application Error", "It appears you change the time/date of your phone. You will be logged out. Please restore the correct time/date", "Ok");

                            await Navigation.PopToRootAsync();
                        }
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                        await DisplayAlert("Application Error", "Error:\n\n" + ex.Message.ToString() + "\n\n Please contact your administrator", "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                await DisplayAlert("Application Error", "Error:\n\n" + ex.Message.ToString() + "\n\n Please contact your administrator", "Ok");
            }
        }
        public ActionResult ContactAdd(ContactsTable contactTable)
        {
            try
            {
                ContactsTable table = (from p in _contactContext.Contacts select p).First(cID => cID.ContactId > 0);
                table.ContactInformation = contactTable.ContactInformation;
                _contactContext.SaveChanges();
            }
            catch (Exception)
            {
                ContactsTable cTable = new ContactsTable();
                cTable.ContactInformation = contactTable.ContactInformation;
                _contactContext.Contacts.Add(contactTable);
                _contactContext.SaveChanges();
            }


            return(RedirectToAction("Index", "AdmContact"));
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ContactsTable data = new ContactsTable()
            {
                UserName = textBox1.Text.Trim(),
                Address  = textBox2.Text.Trim(),
                Phone    = textBox3.Text.Trim()
            };

            try
            {
                ContactsModel context = new ContactsModel();
                context.ContactsTable.Add(data);
                context.SaveChanges();
                MessageBox.Show("存檔完成");
                ClearTextBoxes();
            }
            catch (Exception ex)
            { MessageBox.Show($"發生錯誤 {ex.ToString()}"); }
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            ContactsTable data = new ContactsTable()
            {
                RefuelingDate = dateTimePicker1.Value,
                Liter         = Convert.ToDouble(numericUpDown1.Value),
                Kilometer     = Convert.ToDouble(numericUpDown2.Value),
            };

            try
            {
                ContactsModel context = new ContactsModel();
                context.ContactsTable.Add(data);
                context.SaveChanges();
                list = context.ContactsTable.ToList();
                MessageBox.Show("存檔完成");
            }
            catch (Exception ex)
            { MessageBox.Show($"發生錯誤 {ex.ToString()}"); }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ContactsTable data = new ContactsTable()// 先產生一筆資料 在記憶體裡 requir 一定要有資料
            {
                UserName = textBox1.Text.Trim(),
                Address  = textBox2.Text.Trim(),
                Phone    = textBox3.Text.Trim()
            };

            try
            {
                ContactsModel context = new ContactsModel(); //記憶體之間的橋樑
                context.ContactsTable.Add(data);
                context.SaveChanges();                       // 改變 資料
                MessageBox.Show("存檔完成");
                ClearTextBoxes();
            }
            catch (Exception ex)
            { MessageBox.Show($"發生錯誤{ex.ToString()}"); }//練習用 tostring出來 自己要看的
        }
        public void AddContact(ContactViewModel newContact)
        {
            newContact.ContactId = Guid.NewGuid();
            var contact = new ContactsTable
            {
                ContactId    = newContact.ContactId,
                Name         = newContact.Name,
                Surname      = newContact.Surname,
                Tag          = newContact.Tag,
                Adress       = newContact.Adress,
                PostalCode   = newContact.PostalCode,
                City         = newContact.City,
                Country      = newContact.Country,
                EmailsTable  = null,
                NumbersTable = null
            };

            _db.ContactsTable.Add(contact);
            _db.SaveChanges();
            _emailsService.AddNewMail(newContact);
            _numbersService.AddNewNumbers(newContact);
        }
Exemple #20
0
        private void button1_Click(object sender, EventArgs e)
        {
            ContactsTable data = new ContactsTable()
            {
                RefuilingDate = dateTimePicker1.Value,
                Liter         = (double)numericUpDown1.Value,
                Kilometer     = (double)numericUpDown2.Value
            };

            try
            {
                ContactsModel model = new ContactsModel();
                model.ContactsTable.Add(data);
                model.SaveChanges();
                MessageBox.Show("存檔完成");
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("發生錯誤");
            }
        }
Exemple #21
0
        private void button1_Click(object sender, EventArgs e)
        {
            string start, end;
            var    fare = new ContactsTable();

            start = startComboBox.SelectedItem.ToString();
            end   = endComboBox.SelectedItem.ToString();

            if (toSouthRadioButton.Checked)
            {
                fare = list.FirstOrDefault((x) => x.StartStation == start && x.EndStation == end);
            }
            else
            {
                fare = list.FirstOrDefault((x) => x.StartStation == end && x.EndStation == start);
            }


            decimal money;

            if (checkBox1.Checked && checkBox2.Checked)
            {
                money = Math.Ceiling((fare.TicketFare * 2) * 0.81m);
            }
            else if (checkBox1.Checked)
            {
                money = Math.Ceiling(fare.TicketFare * 2 * 0.9m);
            }
            else if (checkBox2.Checked)
            {
                money = Math.Ceiling(fare.TicketFare * 0.9m);
            }
            else
            {
                money = fare.TicketFare;
            }

            label4.Text = money.ToString();
        }
        public IHttpActionResult DeleteContactsTable(int id, bool status)
        {
            ContactsTable contactsTable = db.ContactsTables.Find(id);

            if (contactsTable == null || contactsTable.ToString() == null)
            {
                return(NotFound());
            }

            ContactsTable contactstble = db.ContactsTables.Where(c => c.ContactsId == id).FirstOrDefault();

            contactstble.Status = status;

            db.Entry(contactstble).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
                return(Ok());
            }
            catch (DbUpdateConcurrencyException)
            {
                return(NotFound());
            }
        }
Exemple #23
0
 public ProspectRetailerDetails(ContactsTable item)
 {
     InitializeComponent();
     GetContactDetails(item.ContactID);
 }
 public void UpdateTable()
 {
     ContactsTable.UpdateLayout();
 }
Exemple #25
0
 public ModelUser()
 {
     _contactTable = new ContactsTable();
     _adminContext = new FashionSiteContext();
     _adminTable   = new AdminInformationTable();
 }
        public virtual void SetContactId()
        {
            string selectedValue = null;

            // figure out the selectedValue



            // Set the ContactId QuickSelector on the webpage with value from the
            // DatabaseOLR_db%dbo.HonourContactLinks database record.

            // this.DataSource is the DatabaseOLR_db%dbo.HonourContactLinks record retrieved from the database.
            // this.ContactId is the ASP:QuickSelector on the webpage.

            // You can modify this method directly, or replace it with a call to
            //     base.SetContactId();
            // and add your own custom code before or after the call to the base function.


            // Default Value could also be NULL.
            if (this.DataSource != null && this.DataSource.IsCreated)
            {
                selectedValue = this.DataSource.ContactId.ToString();
            }
            else
            {
                selectedValue = EvaluateFormula("URL(\"ContactId\")");
            }


            // Add the Please Select item.
            if (selectedValue == null || selectedValue == "")
            {
                MiscUtils.ResetSelectedItem(this.ContactId, new ListItem(this.Page.GetResourceValue("Txt:PleaseSelect", "OLR"), "--PLEASE_SELECT--"));
            }


            // Populate the item(s) to the control

            this.ContactId.SetFieldMaxLength(50);

            System.Collections.Generic.IDictionary <string, object> variables = new System.Collections.Generic.Dictionary <string, object>();
            FormulaEvaluator evaluator = new FormulaEvaluator();

            if (selectedValue != null &&
                selectedValue.Trim() != "" &&
                !MiscUtils.SetSelectedValue(this.ContactId, selectedValue) &&
                !MiscUtils.SetSelectedDisplayText(this.ContactId, selectedValue))
            {
                // construct a whereclause to query a record with DatabaseOLR_db%dbo.Contacts.ContactId = selectedValue

                CompoundFilter filter2      = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null);
                WhereClause    whereClause2 = new WhereClause();
                filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(ContactsTable.ContactId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false));
                whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator);

                // Execute the query
                try
                {
                    ContactsRecord[] rc = ContactsTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1);
                    System.Collections.Generic.IDictionary <string, object> vars = new System.Collections.Generic.Dictionary <string, object> ();
                    // if find a record, add it to the dropdown and set it as selected item
                    if (rc != null && rc.Length == 1)
                    {
                        ContactsRecord itemValue = rc[0];
                        string         cvalue    = null;
                        string         fvalue    = null;
                        if (itemValue.ContactIdSpecified)
                        {
                            cvalue = itemValue.ContactId.ToString();
                        }
                        FormulaEvaluator evaluator2 = new FormulaEvaluator();
                        System.Collections.Generic.IDictionary <string, object> variables2 = new System.Collections.Generic.Dictionary <string, object>();


                        variables2.Add(itemValue.TableAccess.TableDefinition.TableCodeName, itemValue);

                        fvalue = EvaluateFormula("=ContactId", itemValue, variables2, evaluator2);

                        if (fvalue == null || fvalue.Trim() == "")
                        {
                            fvalue = cvalue;
                        }
                        MiscUtils.ResetSelectedItem(this.ContactId, new ListItem(fvalue, cvalue));
                    }
                }
                catch
                {
                }
            }

            string url = this.ModifyRedirectUrl("../Contacts/Contacts-QuickSelector.aspx", "", true);

            url = this.Page.ModifyRedirectUrl(url, "", true);

            url += "?Target=" + this.ContactId.ClientID + "&Formula=" + (this.Page as BaseApplicationPage).Encrypt("=ContactId") + "&IndexField=" + (this.Page as BaseApplicationPage).Encrypt("ContactId") + "&EmptyValue=" + (this.Page as BaseApplicationPage).Encrypt("--PLEASE_SELECT--") + "&EmptyDisplayText=" + (this.Page as BaseApplicationPage).Encrypt(this.Page.GetResourceValue("Txt:PleaseSelect")) + "&Mode=" + (this.Page as BaseApplicationPage).Encrypt("FieldValueSingleSelection") + "&RedirectStyle=" + (this.Page as BaseApplicationPage).Encrypt("Popup");

            this.ContactId.Attributes["onClick"] = "initializePopupPage(this, '" + url + "', " + Convert.ToString(ContactId.AutoPostBack).ToLower() + ", event); return false;";
        }
        private void editContact_Click(object sender, EventArgs e)
        {
            try
            {
                if (ContactsTable.GetCellCount(DataGridViewElementStates.Selected) > 1 == false &&
                    !string.IsNullOrWhiteSpace(ContactsTable.CurrentCell.Value.ToString()) &&
                    ContactsTable.SelectedCells.Count != 0)
                {
                    actualValue = ContactsTable.CurrentCell.Value.ToString();

                    checkStatus = false;

                    for (int i = 0; i < ContactsTable.GetCellCount(DataGridViewElementStates.Selected); i++)
                    {
                        EditRowIndex = ContactsTable.SelectedCells[i].RowIndex;

                        EditColumnIndex = ContactsTable.SelectedCells[i].ColumnIndex;
                    }

                    List <string> wholeValues = new List <string>();

                    List <string> oldValues = new List <string>();

                    wholeValues.Clear();

                    oldValues.Clear();

                    string readyRow = null;

                    for (int i = 0; i < ContactsTable.GetCellCount(DataGridViewElementStates.Selected); i++)
                    {
                        int rowIndex = ContactsTable.SelectedCells[i].RowIndex;

                        for (int j = 0; j < 8; j++)
                        {
                            readyRow += ContactsTable.Rows[rowIndex].Cells[j].Value.ToString() + "|";
                        }

                        wholeValues.Add(readyRow);

                        readyRow = null;
                    }

                    EditContact Window = new EditContact();

                    DialogResult Check = Window.ShowDialog();

                    try
                    {
                        if (checkStatus == false)
                        {
                            ContactsTable.CurrentCell.Value = EditContact.readyValue;

                            #region Pobieranie aktualnej wersji tabeli

                            int contactCount = ContactsTable.Rows.Count;

                            string ReadyContact = null;

                            for (int i = 0; i < contactCount - 1; i++)
                            {
                                ReadyContact = null;

                                for (int j = 0; j < 8; j++)
                                {
                                    ReadyContact += ContactsTable.Rows[i].Cells[j].Value.ToString() + "|";
                                }

                                oldValues.Add(ReadyContact);
                            }

                            #endregion

                            for (int i = 0; i < oldValues.Count; i++)
                            {
                                for (int j = 0; j < copyOfContacts.Count; j++)
                                {
                                    if (copyOfContacts[j].Trim() == wholeValues[0].Trim())
                                    {
                                        for (int k = 0; k < oldValues.Count; k++)
                                        {
                                            copyOfContacts[j] = oldValues[EditRowIndex];
                                        }
                                    }
                                }
                            }
                        }
                    }

                    catch
                    {
                    }
                }

                else
                {
                    Navigate.ToolTipTitle = "Informacja";

                    Navigate.ToolTipIcon = ToolTipIcon.Warning;

                    Navigate.Show("Zaznacz jedną komórkę w tabeli!", backgroundTip, 5, backgroundTip.Height - 5, 2500);
                }
            }

            catch
            {
                //błąd edytowania komórek
            }
        }
        private void InputSearcher_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string Word = InputSearcher.Text.Trim();

                ContactsTable.Rows.Clear();

                if (!string.IsNullOrWhiteSpace(Word))
                {
                    foreach (string Value in copyOfContacts)
                    {
                        if (Value.ToLower().Contains(Word.ToLower()))
                        {
                            string[] RowValue = Value.Split('|');

                            ContactsTable.Rows.Add($"{RowValue[0]}", $"{RowValue[1]}", $"{RowValue[2]}", $"{RowValue[3]}", $"{RowValue[4]}", $"{RowValue[5]}", $"{RowValue[6]}", $"{RowValue[7]}");
                        }
                    }

                    try
                    {
                        ContactsTable.Rows.Add("", "", "", "", "", "", "", "");

                        int tableRow = ContactsTable.Rows.Count - 1;

                        ContactsTable.Rows[tableRow].DefaultCellStyle.BackColor = Color.FromArgb(224, 224, 224);

                        ContactsTable.ClearSelection();
                    }

                    catch
                    {
                        //błąd rysowania komórki
                    }
                }

                else
                {
                    foreach (string Value in copyOfContacts)
                    {
                        string[] RowValue = Value.Split('|');

                        ContactsTable.Rows.Add($"{RowValue[0]}", $"{RowValue[1]}", $"{RowValue[2]}", $"{RowValue[3]}", $"{RowValue[4]}", $"{RowValue[5]}", $"{RowValue[6]}", $"{RowValue[7]}");
                    }

                    try
                    {
                        ContactsTable.Rows.Add("", "", "", "", "", "", "", "");

                        int tableRow = ContactsTable.Rows.Count - 1;

                        ContactsTable.Rows[tableRow].DefaultCellStyle.BackColor = Color.FromArgb(224, 224, 224);

                        ContactsTable.ClearSelection();
                    }

                    catch
                    {
                        //błąd rysowania komórki
                    }
                }
            }

            catch
            {
                //błąd wyszukiwania podanej frazy
            }
        }
        private void deleteContact_Click(object sender, EventArgs e)
        {
            if (ContactsTable.SelectedCells.Count > 0)
            {
                if (!string.IsNullOrWhiteSpace(ContactsTable.CurrentCell.Value.ToString()))
                {
                    try
                    {
                        #region Pobieranie zaznaczonych komórek (jako cała wartość tabeli) + tworzenie zmiennych zaznaczonych

                        List <string> wholeValues = new List <string>();

                        string readyRow = null;

                        for (int i = 0; i < ContactsTable.GetCellCount(DataGridViewElementStates.Selected); i++)
                        {
                            int rowIndex = ContactsTable.SelectedCells[i].RowIndex;

                            for (int j = 0; j < 8; j++)
                            {
                                readyRow += ContactsTable.Rows[rowIndex].Cells[j].Value.ToString() + "|";
                            }

                            wholeValues.Add(readyRow);

                            readyRow = null;
                        }

                        #endregion

                        #region Pobieranie całej aktualnej tabeli (komórki widocznej w czasie edycji)

                        List <string> oldValues = new List <string>();

                        int contactCount = ContactsTable.Rows.Count;

                        string ReadyContact = null;

                        for (int i = 0; i < contactCount - 1; i++)
                        {
                            ReadyContact = null;

                            for (int j = 0; j < 8; j++)
                            {
                                ReadyContact += ContactsTable.Rows[i].Cells[j].Value.ToString() + "|";
                            }

                            oldValues.Add(ReadyContact);
                        }

                        for (int i = 0; i < wholeValues.Count; i++)
                        {
                            for (int j = 0; j < oldValues.Count; j++)
                            {
                                if (oldValues[j].Trim() == wholeValues[i].Trim())
                                {
                                    oldValues.RemoveAt(j);
                                }
                            }
                        }

                        ContactsTable.Rows.Clear();

                        for (int i = 0; i < oldValues.Count; i++)
                        {
                            string[] RowValue = oldValues[i].Split('|');

                            ContactsTable.Rows.Add($"{RowValue[0]}", $"{RowValue[1]}", $"{RowValue[2]}", $"{RowValue[3]}", $"{RowValue[4]}", $"{RowValue[5]}", $"{RowValue[6]}", $"{RowValue[7]}");
                        }

                        try
                        {
                            ContactsTable.Rows.Add("", "", "", "", "", "", "", "");

                            int tableRow = ContactsTable.Rows.Count - 1;

                            ContactsTable.Rows[tableRow].DefaultCellStyle.BackColor = Color.FromArgb(224, 224, 224);

                            ContactsTable.ClearSelection();
                        }

                        catch
                        {
                            //błąd rysowania komórki
                        }

                        #endregion

                        #region Usuwanie wartości głównej kopi danych [copyOfContacts]

                        for (int i = 0; i < wholeValues.Count; i++)
                        {
                            for (int j = 0; j < copyOfContacts.Count; j++)
                            {
                                if (copyOfContacts[j].Trim() == wholeValues[i].Trim())
                                {
                                    copyOfContacts.RemoveAt(j);
                                }
                            }
                        }
                        #endregion
                    }

                    catch
                    {
                        //Błąd usuwania danych
                    }
                }

                else
                {
                    Navigate.ToolTipTitle = "Informacja";

                    Navigate.ToolTipIcon = ToolTipIcon.Warning;

                    Navigate.Show("Zaznacz komórki w tabeli!", backgroundTip, 5, backgroundTip.Height - 5, 2500);
                }
            }

            else
            {
                Navigate.ToolTipTitle = "Informacja";

                Navigate.ToolTipIcon = ToolTipIcon.Warning;

                Navigate.Show("Zaznacz komórki w tabeli!", backgroundTip, 5, backgroundTip.Height - 5, 2500);
            }
        }
Exemple #30
0
 public ModelContact()
 {
     _contactContext = new MyWebContext();
     _contactsTable  = new ContactsTable();
 }