Exemple #1
0
        private void form_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if ((DateTime.Now - date) < TimeSpan.FromMilliseconds(30))
                {
                    if (e.KeyCode == Keys.Enter)
                    {
                        //string inputInfo = ";111=125001=3=63115235?";
                        //MatchCollection matches = Regex.Matches(inputInfo, @"([0-9])+");
                        MatchCollection matches   = Regex.Matches(Encoding.ASCII.GetString(stk.get()), @"([0-9])+");
                        string          inputInfo = Encoding.ASCII.GetString(stk.get());
                        if (matches.Count >= 3)
                        {
                            var ip = GetLocalIPAddress();
                            loginInfo = new LoginInfo(inputInfo, ip.MapToIPv4().ToString());

                            LoginInfo.LoginInfoResponce loginInfoResponce = new LoginInfo.LoginInfoResponce();
                            GetCashierInfo();
                            stk.clear();
                            return;
                        }
                        stk.clear();
                    }
                    stk.push((byte)e.KeyValue);
                }
            }
            catch (Exception exc)
            {
                stk.clear();
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();
            }
        }
Exemple #2
0
        public bool IsCardPaid()
        {
            APP_PATH = ConfigurationManager.AppSettings.Get("serverURI");
            var      httpWebRequest      = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/IsCardPaid/");
            CardInfo cardInfoForGetPrice = new CardInfo(cardInfo, loginCardInfo, ip);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(cardInfoForGetPrice);
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }
            var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            string result       = "";

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    if (result == "null")
                    {
                        throw new Exception("Ошибка получения данных о оплате карты");
                    }
                    else
                    {
                        string    r         = result.Remove(result.Length - 1);
                        var       k         = JsonConvert.DeserializeObject(result);
                        CardPrice cardPrice = JsonConvert.DeserializeObject <CardPrice>(k.ToString());
                        if (cardPrice != null && cardPrice.cardPrice > 0)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                else if (httpResponse.StatusCode == HttpStatusCode.NotFound)
                {
                    result = streamReader.ReadToEnd();
                    FormMessage formMessage = new FormMessage(result, "Касса");
                    formMessage.Show();
                }
                else if (httpResponse.StatusCode == HttpStatusCode.NotAcceptable)
                {
                    result = streamReader.ReadToEnd();
                    FormMessage formMessage = new FormMessage(result, "Касса");
                    formMessage.Show();
                }
                return(false);
            }
        }
Exemple #3
0
 private void clearCalcButton_Click(object sender, EventArgs e)
 {
     try
     {
         calcTextBox.Text = "";
     }
     catch (Exception exc)
     {
         FormMessage formMessage = new FormMessage(exc.Message, "Касса");
         formMessage.Show();
     }
 }
Exemple #4
0
        public static decimal GetCardPrice(string loginCardInfo, string ip)
        {
            APP_PATH = ConfigurationManager.AppSettings.Get("serverURI");
            var       httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/getcardprice/");
            LoginInfo loginInfo      = new LoginInfo(loginCardInfo, ip);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(loginInfo);
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }
            var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            string result       = "";

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    if (result == "null")
                    {
                        throw new Exception("Ошибка получения стоимости карты");
                    }
                    else
                    {
                        //string r = result.Remove(result.Length - 1);
                        //var k = JsonConvert.DeserializeObject(result);
                        //cardPrice = JsonConvert.DeserializeObject<decimal>(k.ToString());
                        string r = result.Trim('\\');
                        result = r.Trim('"');
                        return(Decimal.Parse(result));
                    }
                }
                else if (httpResponse.StatusCode == HttpStatusCode.NotFound)
                {
                    result = streamReader.ReadToEnd();
                    FormMessage formMessage = new FormMessage(result, "Касса");
                    formMessage.Show();
                }
                else if (httpResponse.StatusCode == HttpStatusCode.NotAcceptable)
                {
                    result = streamReader.ReadToEnd();
                    FormMessage formMessage = new FormMessage(result, "Касса");
                    formMessage.Show();
                }
                return(0);
            }
        }
Exemple #5
0
 public void returnCashForCard(string cardInfoString, string loginCard, string ip)
 {
     try
     {
         var      httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/ReturnCashForCard/");
         CardInfo cardInfo       = new CardInfo(cardInfoString, loginCard, ip);
         httpWebRequest.ContentType = "application/json";
         httpWebRequest.Method      = "POST";
         using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
         {
             string json = JsonConvert.SerializeObject(cardInfo);
             streamWriter.Write(json);
             streamWriter.Flush();
             streamWriter.Close();
         }
         var       httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
         CardPrice cardPrice    = new CardPrice();
         string    result       = "";
         using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
         {
             result = streamReader.ReadToEnd();
             if (result == "null")
             {
                 throw new Exception("Ошибка возврата стоимостик карты");
             }
             else
             {
                 string r = result.Remove(result.Length - 1);
                 var    k = JsonConvert.DeserializeObject(result);
                 cardPrice = JsonConvert.DeserializeObject <CardPrice>(k.ToString());
                 if (cardPrice.cardId == cardId)
                 {
                     if (cardPrice.cardPrice > 0)
                     {
                         FormMessage formMessage = new FormMessage("Стоимость карты уже возвращена", " Касса");
                         formMessage.Show();
                     }
                     else
                     {
                         FormMessage formMessage = new FormMessage("Стоимость карты возвращена", " Касса");
                         formMessage.Show();
                     }
                 }
             }
         }
     }
     catch (Exception exc)
     {
         FormMessage formMessage = new FormMessage(exc.Message, "Касса");
         formMessage.Show();
     }
 }
Exemple #6
0
 private void calcBtn_Click(object sender, EventArgs e)
 {
     try
     {
         var btn = sender as Button;
         calcTextBox.Text += btn.Text;
     }
     catch (Exception exc)
     {
         FormMessage formMessage = new FormMessage(exc.Message, "Касса");
         formMessage.Show();
     }
 }
Exemple #7
0
 public void removeCard(string cardInfoString, string loginCard, string ip)
 {
     try
     {
         if (cardCount > 0)
         {
             var      httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/RemoveCard/");
             CardInfo cardInfo       = new CardInfo(cardInfoString, loginCard, ip);
             httpWebRequest.ContentType = "application/json";
             httpWebRequest.Method      = "POST";
             using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
             {
                 string json = JsonConvert.SerializeObject(cardInfo);
                 streamWriter.Write(json);
                 streamWriter.Flush();
                 streamWriter.Close();
             }
             var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
             Card   card         = new Card();
             string result       = "";
             using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
             {
                 result = streamReader.ReadToEnd();
                 if (result == "null")
                 {
                     throw new Exception("Ошибка возврата карты");
                 }
                 else
                 {
                     string r = result.Remove(result.Length - 1);
                     var    k = JsonConvert.DeserializeObject(result);
                     card            = JsonConvert.DeserializeObject <Card>(k.ToString());
                     this.cardCount  = card.cardCount;
                     this.cardBonus  = card.cardBonus;
                     this.cardTicket = card.cardTicket;
                     this.cardStatus = card.cardStatus;
                     this.cardSale   = card.cardSale;
                 }
             }
         }
         else
         {
             throw new Exception("На счету 0");
         }
     }
     catch (Exception exc)
     {
         FormMessage formMessage = new FormMessage(exc.Message, "Касса");
         formMessage.Show();
     }
 }
Exemple #8
0
        public void removeDayBonuses(string cardInfo, string loginCard, string ip, decimal dayBonuses)
        {
            try
            {
                decimal balance = this.cardDayBonus;
                if (balance >= dayBonuses)
                {
                    ReplenishmentInfo replenishmentInfo = new ReplenishmentInfo(cardInfo, dayBonuses, 0, 0, loginCard, ip);
                    var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/ReturnDayBonuses/");

                    httpWebRequest.ContentType = "application/json";
                    httpWebRequest.Method      = "POST";
                    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                    {
                        string json = JsonConvert.SerializeObject(replenishmentInfo);
                        streamWriter.Write(json);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }
                    var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    Card   card         = new Card();
                    string result       = "";
                    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        result = streamReader.ReadToEnd();
                        if (result == "null")
                        {
                            throw new Exception("Ошибка списания бонусов");
                        }
                        else
                        {
                            string r = result.Remove(result.Length - 1);
                            var    k = JsonConvert.DeserializeObject(result);
                            card = JsonConvert.DeserializeObject <Card>(k.ToString());
                            this.cardDayBonus = card.cardDayBonus;
                        }
                    }
                }
                else
                {
                    throw new Exception("Недосточное количесво суточных бонусов");
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int n = 0;

            if (Int32.TryParse(textBox1.Text, out n))
            {
                this.number = n;
                Close();
            }
            else
            {
                FormMessage formMessage = new FormMessage("Введите число", "Касса");
                formMessage.Show();
            }
        }
Exemple #10
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Card.isDefined(currentCard))
         {
             throw new Exception("Карта не определена");
         }
         if (calcTextBox.Text.Length <= 0)
         {
             throw new Exception("Введите значение в поле ввода");
         }
         money = decimal.Parse(calcTextBox.Text);
         if (money <= moneyLeft)
         {
             if (!isCardPaid)
             {
                 moneyForCard = PaidForCard().cardPrice;
             }
             if (radioButton1.Checked)
             {
                 currentCard.replenishment(cardInfo, money, 0, 0, loginCardInfo, ip);
                 dialogResult = DialogResult.Yes;
             }
             else if (radioButton2.Checked)
             {
                 currentCard.replenishment(cardInfo, 0, money, 0, loginCardInfo, ip);
                 dialogResult = DialogResult.Yes;
             }
             else if (radioButton3.Checked)
             {
                 currentCard.replenishment(cardInfo, 0, 0, money, loginCardInfo, ip);
                 dialogResult = DialogResult.Yes;
             }
         }
         else
         {
             throw new Exception("Введена сумма больше полученной");
         }
         Close();
     }
     catch (Exception exc)
     {
         FormMessage formMessage = new FormMessage(exc.Message, "Касса");
         formMessage.Show();
         dialogResult = DialogResult.No;
     }
 }
Exemple #11
0
 private void backspaceCalcButton_Click(object sender, EventArgs e)
 {
     try
     {
         var text = calcTextBox.Text;
         if (text.Length > 0)
         {
             calcTextBox.Text = text.Substring(0, text.Length - 1);
         }
     }
     catch (Exception exc)
     {
         FormMessage formMessage = new FormMessage(exc.Message, "Касса");
         formMessage.Show();
     }
 }
Exemple #12
0
        //Регистрация новой карты
        public static Card register(
            string cardInfo,
            string loginCard,
            string ip,
            bool swap)
        {
            try
            {
                RegistretedCardInfo registretedCardInfo = new RegistretedCardInfo(cardInfo, loginCard, ip, swap);
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/RegisterateNewCard/");

                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(registretedCardInfo);
                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                Card   card         = new Card();
                string result       = "";
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                    if (result == "null")
                    {
                        throw new Exception("Ошибка регистарции карты");
                    }
                    else
                    {
                        string r = result.Remove(result.Length - 1);
                        var    k = JsonConvert.DeserializeObject(result);
                        card = JsonConvert.DeserializeObject <Card>(k.ToString());
                        return(card);
                    }
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();

                return(null);
            }
        }
Exemple #13
0
        private StartInfo getStartInfo(string loginCardInfo, string ip)
        {
            try
            {
                LoginInfo loginInfo      = new LoginInfo(loginCardInfo, ip);
                var       httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/GetStartInfo/");

                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(loginInfo);
                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var       httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                StartInfo startInfo    = new StartInfo();
                string    result       = "";
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                    if (result == "null")
                    {
                        throw new Exception("Ошибка получения данных для запуска");
                    }
                    else
                    {
                        string r = result.Remove(result.Length - 1);
                        var    k = JsonConvert.DeserializeObject(result);
                        startInfo = JsonConvert.DeserializeObject <StartInfo>(k.ToString());
                        return(startInfo);
                    }
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();

                return(null);
            }
        }
Exemple #14
0
        //Установка пакета
        public void setPacket(string cardInfo, int discount, string loginCard, string ip)
        {
            try
            {
                int balance = this.cardTicket;
                ReplenishmentInfo replenishmentInfo = new ReplenishmentInfo(cardInfo, discount, 0, 0, loginCard, ip);
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/SetPacket/");

                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(replenishmentInfo);
                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                Card   card         = new Card();
                string result       = "";
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                    if (result == "null" || result == "\"null\"")
                    {
                        throw new Exception("Ошибка установки пакета");
                    }
                    else
                    {
                        string r = result.Remove(result.Length - 1);
                        var    k = JsonConvert.DeserializeObject(result);
                        card          = JsonConvert.DeserializeObject <Card>(k.ToString());
                        this.cardSale = card.cardSale;
                    }
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();
            }
        }
Exemple #15
0
        //Пополнение баланса
        public void replenishment(string cardInfo, decimal cash, decimal cashlessPayment, decimal creditCard, string loginCard, string ip)
        {
            try
            {
                ReplenishmentInfo replenishmentInfo = new ReplenishmentInfo(cardInfo, cash, cashlessPayment, creditCard, loginCard, ip);
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/Replenishment/");

                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(replenishmentInfo);
                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                Card   card         = new Card();
                string result       = "";
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                    if (result == "null")
                    {
                        throw new Exception("Ошибка пополнения очков");
                    }
                    else
                    {
                        string r = result.Remove(result.Length - 1);
                        var    k = JsonConvert.DeserializeObject(result);
                        card           = JsonConvert.DeserializeObject <Card>(k.ToString());
                        this.cardCount = card.cardCount;
                    }
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();
            }
        }
Exemple #16
0
        public CardPrice PaidForCard()
        {
            APP_PATH = ConfigurationManager.AppSettings.Get("serverURI");
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/PaidForCard/");
            ReplenishmentInfo replenishmentInfo = new ReplenishmentInfo();

            if (radioButton1.Checked)
            {
                replenishmentInfo = new ReplenishmentInfo(cardInfo, cash, 0, 0, loginCardInfo, ip);
            }
            else if (radioButton2.Checked)
            {
                replenishmentInfo = new ReplenishmentInfo(cardInfo, 0, cash, 0, loginCardInfo, ip);
            }
            else if (radioButton3.Checked)
            {
                replenishmentInfo = new ReplenishmentInfo(cardInfo, 0, 0, cash, loginCardInfo, ip);
            }
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(replenishmentInfo);
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }
            var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            string result       = "";

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    if (result == "null")
                    {
                        throw new Exception("Ошибка оплаты карты");
                    }
                    else
                    {
                        string r = result.Remove(result.Length - 1);
                        var    k = JsonConvert.DeserializeObject(result);
                        return(JsonConvert.DeserializeObject <CardPrice>(k.ToString()));
                    }
                }
                else if (httpResponse.StatusCode == HttpStatusCode.NotFound)
                {
                    result = streamReader.ReadToEnd();
                    FormMessage formMessage = new FormMessage(result, "Касса");
                    formMessage.Show();
                }
                else if (httpResponse.StatusCode == HttpStatusCode.NotAcceptable)
                {
                    result = streamReader.ReadToEnd();
                    FormMessage formMessage = new FormMessage(result, "Касса");
                    formMessage.Show();
                }
                return(null);
            }
        }
Exemple #17
0
        private void GetCashierInfo()
        {
            try
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/GetCashierInfo/");
                var ip             = GetLocalIPAddress();
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                LoginInfo newLoginInfo = new LoginInfo(loginInfo.cardInfo, ip.MapToIPv4().ToString());
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = JsonConvert.SerializeObject(newLoginInfo, Formatting.Indented, new JsonSerializerSettings
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    });
                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                LoginInfo.LoginInfoResponce loginInfoResponce = new LoginInfo.LoginInfoResponce();
                string result = "";
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                    if (result != "null")
                    {
                        string r = result.Remove(result.Length - 1);
                        var    k = JsonConvert.DeserializeObject(result);

                        loginInfoResponce = JsonConvert.DeserializeObject <LoginInfo.LoginInfoResponce>(k.ToString());
                    }
                    else
                    {
                        throw new Exception("Ошибка данных кассира/кассы");
                    }
                }
                if (loginInfoResponce != null)
                {
                    StartInfo startInfo = getStartInfo(newLoginInfo.cardInfo, ip.MapToIPv4().ToString());
                    if (startInfo != null)
                    {
                        form formCashRegister = new form(
                            loginInfoResponce.cashier,
                            loginInfoResponce.cashierRegister,
                            newLoginInfo.cardInfo,
                            ip.MapToIPv4().ToString(),
                            startInfo
                            );
                        this.Hide();
                        formCashRegister.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        FormMessage formMessage = new FormMessage("Ошибка получения начальных данных.", "Касса");
                        formMessage.Show();
                    }
                }
                else if (loginInfoResponce == null)
                {
                    FormMessage formMessage = new FormMessage("Ошибка входа.\nПроверьте карту.", "Касса");
                    formMessage.Show();
                }
                else
                {
                    FormMessage formMessage = new FormMessage(httpResponse.StatusDescription, "Касса");
                    formMessage.Show();
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();
            }
        }
        private void changeInfoButton_Click(object sender, EventArgs e)
        {
            try
            {
                string      parentName      = "";
                Card        card            = form.selectCard(cardInfo, loginCard, ip);
                ClientsInfo clientsInfo     = new ClientsInfo();
                int         numberOfClients = 0;
                if (!(String.IsNullOrEmpty(richTextBoxFIOparent.Text.ToString())) && richTextBoxFIOparent.Text.ToString().Trim() != string.Empty)
                {
                    parentName = richTextBoxFIOparent.Text.ToString();
                }
                else
                {
                    throw new Exception("Введено не верное значение ФИО родителя");
                }
                clientsInfo.email = textBoxEmail.Text;
                if (!String.IsNullOrEmpty(maskedTextBoxTelephone.Text.ToString()) && (maskedTextBoxTelephone.Text.ToString().Trim() != string.Empty) &&
                    (Regex.IsMatch(maskedTextBoxTelephone.Text.ToString(), @"(\+7|8|\b)[\(\s-]*(\d)[\s-]*(\d)[\s-]*(\d)[)\s-]*(\d)[\s-]*(\d)[\s-]*(\d)[\s-]*(\d)[\s-]*(\d)[\s-]*(\d)[\s-]*(\d)")))
                {
                    clientsInfo.telephone = maskedTextBoxTelephone.Text;
                }
                else
                {
                    throw new Exception("Не правильно введен телефон");
                }
                if (!checkBoxAdultCard.Checked)
                {
                    clients.Clear();
                    for (int i = 5; i < tableLayoutPanel1.RowCount; i += 2)
                    {
                        bool   enabledControl = true;
                        string childrenName   = "";
                        string childrenDate   = "";
                        foreach (Control control in this.tableLayoutPanel1.Controls)
                        {
                            TableLayoutPanelCellPosition controlPosition = new TableLayoutPanelCellPosition(1, i);
                            if (control is RichTextBox && tableLayoutPanel1.GetPositionFromControl(control) == controlPosition)
                            {
                                if (control.Enabled == true)
                                {
                                    enabledControl = true;
                                    if (!(String.IsNullOrEmpty(control.Text.ToString())) && control.Text.ToString().Trim() != string.Empty)
                                    {
                                        childrenName = control.Text.ToString();
                                    }
                                    else
                                    {
                                        throw new Exception("Введено не верное значение ФИО ребенка");
                                    }
                                }
                                else
                                {
                                    enabledControl = false;
                                }
                            }
                            controlPosition = new TableLayoutPanelCellPosition(1, i + 1);
                            if (control is MaskedTextBox && tableLayoutPanel1.GetPositionFromControl(control) == controlPosition)
                            {
                                if (control.Enabled == true)
                                {
                                    if (!(String.IsNullOrEmpty(control.Text.ToString())) && (control.Text.ToString().Trim() != string.Empty) && (Regex.IsMatch(control.Text.ToString(), "^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)")))
                                    {
                                        childrenDate = control.Text.ToString();
                                    }
                                    else
                                    {
                                        throw new Exception("Введено не верное значение даты рождения ребенка");
                                    }
                                }
                                else
                                {
                                    enabledControl = false;
                                }
                            }
                        }
                        if (enabledControl == true)
                        {
                            numberOfClients++;
                            clients.Add(new Client {
                                cardId = card.cardId, childrenName = childrenName, childrenDate = DateTime.Parse(childrenDate), parentName = parentName, adultCard = false
                            });
                        }
                    }
                }
                else if (checkBoxAdultCard.Checked && richTextBoxesFIOchildrenExsist.Count != 0)
                {
                    string message = "Данные о детях будут удалены. Продолжить?";
                    string caption = "Данные о детях";
                    //MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult result = new DialogResult();

                    FormMessage formMessage = new FormMessage(message, caption, result);
                    formMessage.ShowDialog();

                    if (formMessage.result == DialogResult.Yes)
                    {
                        clients.Clear();
                        numberOfClients = 0;
                        clients.Add(new Client {
                            cardId = card.cardId, childrenName = "", childrenDate = new DateTime().AddYears(1900).AddMonths(1).AddDays(1), parentName = parentName, adultCard = true
                        });
                    }
                    else
                    {
                        throw new Exception("Данные не внесенны");
                    }
                }
                else
                {
                    clients.Clear();
                    numberOfClients = 0;
                    clients.Add(new Client {
                        cardId = card.cardId, childrenName = "", childrenDate = new DateTime().AddYears(1900).AddMonths(1).AddDays(1), parentName = parentName, adultCard = true
                    });
                }
                if (clients.Count != 0)
                {
                    clientsInfo = new ClientsInfo(cardInfo, loginCard, ip, parentName, numberOfClients, clientsInfo.email, clientsInfo.telephone, clients);
                }
                else
                {
                    clients.Add(new Client {
                        cardId = card.cardId, childrenName = "", childrenDate = new DateTime().AddYears(1900).AddMonths(1).AddDays(1), parentName = parentName, adultCard = false
                    });
                    clientsInfo = new ClientsInfo(cardInfo, loginCard, ip, parentName, numberOfClients, clientsInfo.email, clientsInfo.telephone, clients);
                }
                if (clientsInfo.clients.Count > 0)
                {
                    var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/cashiermashine/ChangeClientInfo/");

                    httpWebRequest.ContentType = "application/json";
                    httpWebRequest.Method      = "POST";
                    using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                    {
                        string json = JsonConvert.SerializeObject(clientsInfo);
                        streamWriter.Write(json);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }
                    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    if (httpResponse.StatusCode == HttpStatusCode.Accepted)
                    {
                        if (tableLayoutPanel1.RowCount <= 3)
                        {
                            throw new Exception("Данные не добавленны.\nПроверте данные формы.");
                        }
                        else
                        {
                            FormMessage formMessage = new FormMessage("Данные успешно добавленны", "Касса");
                            formMessage.ShowDialog();
                            Close();
                        }
                    }
                    else if (httpResponse.StatusCode == HttpStatusCode.NoContent)
                    {
                        throw new Exception("Ошибка при добавлении информации о клиентах");
                    }
                    else
                    {
                        throw new Exception(httpResponse.StatusDescription);
                    }
                }
            }
            catch (Exception exc)
            {
                FormMessage formMessage = new FormMessage(exc.Message, "Касса");
                formMessage.Show();
            }
        }