示例#1
0
 public FormChangeCashier(Cashier cashier, Admin admin)
 {
     InitializeComponent();
     this.cashier               = cashier;
     APP_PATH                   = ConfigurationManager.AppSettings.Get("serverURI");
     cashierCardTextBox.Text    = cashier.cashierCardId.ToString();
     cashierFIORichTextBox.Text = cashier.cashierName.ToString();
     cashierIdTextBox.Text      = cashier.cashierId.ToString();
     this.admin                 = admin;
 }
示例#2
0
 public CashierInfo(
     Cashier cashier,
     string cardInfoString,
     Admin admin
     )
 {
     this.cashier        = cashier;
     this.cardInfoString = cardInfoString;
     this.admin          = admin;
 }
示例#3
0
 public void changeCashierButtonsButton_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == cashierDataGridView.Columns["change_column"].Index && e.RowIndex >= 0)
     {
         int               column            = cashierDataGridView.Columns["cashierId"].Index;
         int               row               = e.RowIndex;
         Cashier           changingCashier   = cashiers.Find(x => (x.cashierId.ToString() == cashierDataGridView[column, row].Value.ToString()));
         FormChangeCashier formChangeCashier = new FormChangeCashier(changingCashier, admin);
         formChangeCashier.ShowDialog();
         loadCashiersInfo();
     }
 }
示例#4
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         CashierInfo cashierInfo = new CashierInfo();
         Cashier     cashier     = new Cashier();
         if (cardInfo != "")
         {
             if (!(String.IsNullOrEmpty(cashierFIORichTextBox.Text.ToString())) && cashierFIORichTextBox.Text.ToString().Trim() != string.Empty)
             {
                 cashier.cashierName = cashierFIORichTextBox.Text.ToString();
             }
             else
             {
                 throw new Exception("Не верное значение ФИО родителя");
             }
             int id;
             if (Int32.TryParse(cashierIdTextBox.Text, out id))
             {
                 cashier.cashierId = id;
             }
             else
             {
                 throw new Exception("Не верное значение поля Id");
             }
             cashierInfo.cashier        = cashier;
             cashierInfo.cardInfoString = cardInfo;
             cashierInfo.admin          = admin;
             var httpWebRequest = (HttpWebRequest)WebRequest.Create(APP_PATH + "/api/AttractionInfo/AddCashier");
             httpWebRequest.ContentType = "application/json";
             httpWebRequest.Method      = "POST";
             using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
             {
                 String json = JsonConvert.SerializeObject(cashierInfo);
                 streamWriter.Write(json);
                 streamWriter.Flush();
                 streamWriter.Close();
             }
             var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
             if (httpResponse.StatusCode == HttpStatusCode.Accepted)
             {
                 Close();
             }
             else if (httpResponse.StatusCode == HttpStatusCode.NotAcceptable)
             {
                 MessageBox.Show("Ошибка добавления кассира");
             }
             else if (httpResponse.StatusCode == HttpStatusCode.NoContent)
             {
                 MessageBox.Show("Кассир с такими параметрами уже существует");
             }
         }
         else
         {
             throw new Exception("Карта не определена. Добавте карту.");
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }