示例#1
0
        private void update_row(STRowPayment item)
        {
            try
            {
                using (OracleConnection connection = new OracleConnection(config.connectionstring))
                {
                    connection.Open();

                    string        query   = "UPDATE RCD.VALID_PAYMENT SET AMOUNT=:2 WHERE PDATE=:1";
                    OracleCommand command = new OracleCommand(query, connection);
                    command.Parameters.Add(crp(OracleType.DateTime, item.dtime, "1", false));
                    command.Parameters.Add(crp(OracleType.Number, Math.Round(item.amount, 2), "2", false));
                    command.ExecuteNonQuery();
                    connection.Close();
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.TargetSite + " " + ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
示例#2
0
        private bool read_file(string FileName, out string msg)
        {
            msg = null;
            int i = 0;

            try
            {
                string FilePath = Path.Combine(inpath, FileName);

                string[] arr_lines = File.ReadAllLines(FilePath);
                // если файл пустой  - ошибка
                if (arr_lines.Length <= 0)
                {
                    msg = "Empty file."; return(false);
                }

                data = new List <STRowPayment>();
                STRowPayment item = new STRowPayment();

                for (i = 0; i < arr_lines.Length; i++)
                {
                    item = new STRowPayment();

                    string[] words = arr_lines[i].Split(';');

                    if (create_row(words[0], words[1], out item, out msg))
                    {
                        data.Add(item);
                    }
                    else
                    {
                        log.LogLine(string.Format("Erorr row's reading {0}, {1})", i, msg));
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                log.LogLine("File wasn't read.");
                return(false);
            }

            return(true);
        }
示例#3
0
        private bool create_row(string data, string amount, out STRowPayment item, out string msg)
        {
            bool ret = true;

            item = new STRowPayment();

            msg = null;
            try
            {
                if (!get_datetime(data, out item.dtime, out msg))
                {
                    return(false);
                }
                if (!double.TryParse(amount, out item.amount))
                {
                    return(false);
                }
            }
            catch (Exception ex) { ret = false; msg = ex.Message; }
            return(ret);
        }