private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(fio_txt.Text))//если текст аббрев или имя_лекарство пустой
            {
                MessageBox.Show("Ному насабро ворид кунед!");
                return;//возврашаемся на форму добавление/изменение
            }
            Form_Jurnal1 = this.Owner as Form_Jurnal;

            if (this.Text.Trim() == "Воридот")
            {
                //вызаваем перегруженный метод ToGrid -DrugsForm , передавая параметры для добавление строки
                Form_Jurnal1.ToGridAdd();
            }

            if (this.Text.Trim() == "Таъғирот")
            {
                //вызаваем перегруженный метод ToGrid -DrugsForm , передавая параметры для изменение строки
                Form_Jurnal1.ToGridEdit();
            }

            this.Close();
            Form_Jurnal1.Activate();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox2.Text))
            {
                return;
            }

            string serial = textBox2.Text;
            string key1   = string.Empty;

            try
            {
                key1 = StatClass.GetKey(serial);
            }
            catch
            {
                MessageBox.Show("Серияи нодуруст ворид шуд!");
                return;
            }
            Form_Jurnal1  = this.Owner as Form_Jurnal;
            textBox3.Text = key1;
            if (this.Text == "Додани калид")
            {
                Form_Jurnal1.setKey();
            }
            else
            {
                DataRow row = Form_Jurnal1.dataTable.NewRow();
                row["num"]           = dataTable.Rows[0]["num"];
                row["customer_type"] = dataTable.Rows[0]["customer_type"];
                row["fio"]           = dataTable.Rows[0]["fio"];
                row["company"]       = dataTable.Rows[0]["company"];
                row["address"]       = dataTable.Rows[0]["address"];
                row["phone"]         = dataTable.Rows[0]["phone"];
                row["passport"]      = dataTable.Rows[0]["passport"];
                row["product_type"]  = dataTable.Rows[0]["product_type"];
                row["realize_type"]  = dataTable.Rows[0]["realize_type"];
                row["data_contract"] = dataTable.Rows[0]["data_contract"];
                row["dataGetKey"]    = dataTable.Rows[0]["dataGetKey"];
                row["serial"]        = dataTable.Rows[0]["serial"];
                row["key1"]          = dataTable.Rows[0]["key1"];
                row["realize"]       = dataTable.Rows[0]["realize"];
                row["send"]          = dataTable.Rows[0]["send"];
                Form_Jurnal1.dataTable.Rows.Add(row);//добавляем новую строку в датаТейбл
                Form_Jurnal1.dataGridView1.Update();
                Form_Jurnal1.dataAdapter.Update(Form_Jurnal1.dataTable);

                Form_Jurnal1.setKey();
            }
            button1.Enabled = false;

            string pathToLog = Path.Combine(Environment.GetEnvironmentVariable("windir"), "tmin");

            if (!Directory.Exists(pathToLog))
            {
                Directory.CreateDirectory(pathToLog); // Создаем директорию, если нужно
            }
            string filePath = Path.Combine(pathToLog, string.Format("{0:MM.yyy}.log", DateTime.Now));
            string fullText = "\r\n" + dataTable.Rows[0]["num"].ToString() + "|" + dataTable.Rows[0]["company"].ToString() + "|" + dataTable.Rows[0]["fio"].ToString() + "|" + dataTable.Rows[0]["product_type"].ToString() + "|"
                              + dataTable.Rows[0]["realize_type"].ToString() + "|" + dataTable.Rows[0]["data_contract"].ToString() + "|" + dataTable.Rows[0]["dataGetKey"].ToString() + "|"
                              + dataTable.Rows[0]["serial"].ToString() + "|" + dataTable.Rows[0]["key1"].ToString();

            File.AppendAllText(filePath, fullText, Encoding.GetEncoding("utf-8"));
        }