Exemple #1
0
        private void importAllButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (login.permission)
                {
                    var            dataToimport = excelData;
                    SqlManipulator sql          = new SqlManipulator();
                    Utility        util         = new Utility();
                    foreach (var data in dataToimport)
                    {
                        var          convertedData = util.convertYekeQuery(data.ToList());
                        var          query         = convertedData.AsQueryable();
                        ComboboxItem itm           = (ComboboxItem)cityComboBox.SelectedItem;
                        long         id            = itm.Value;
                        sql.excelToSqlCopy(query, id);
                    }
                }
                else
                {
                    var            dataToimport = excelData;
                    SqlManipulator sql          = new SqlManipulator();
                    Utility        util         = new Utility();
                    foreach (var data in dataToimport)
                    {
                        var convertedData = util.convertYekeQuery(data.ToList());
                        var query         = convertedData.AsQueryable();

                        sql.excelToSqlCopy(query, login.cityID);
                    }
                }

                this.mainForm.refreshDGV();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Data.ToString());
            }
            this.Hide();
        }
Exemple #2
0
        private void importButton1_Click(object sender, EventArgs e)
        {
            try
            {
                if (refundRadioButton.Checked == false && depositRadioButton.Checked == false)
                {
                    MessageBox.Show("  لطفا نوع فایل را انتخاب  نمایید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                // StartProgress();
                if (login.permission)
                {
                    var dataToimport = excelData[excelMonthscomboBox.SelectedIndex];

                    SqlManipulator sql = new SqlManipulator();


                    ExcelManipulatorcs excel = new ExcelManipulatorcs();
                    var query = excel.dataCorrection(dataToimport);

                    var  itm = (ComboboxItem)cityComboBox.SelectedItem;
                    long id  = itm.Value;

                    if (this.refundRadioButton.Checked)
                    {
                        var      report = sql.refundFromFile(query, id);
                        Reporter rpt    = new Reporter(report, Convert.ToInt32(errorImages.info));
                        rpt.Show();
                    }
                    if (this.depositRadioButton.Checked)
                    {
                        sql.excelToSqlCopy(query, id);
                    }

                    this.mainForm.refreshDGV();
                }
                else
                {
                    Utility        util         = new Utility();
                    var            dataToimport = excelData[excelMonthscomboBox.SelectedIndex];
                    SqlManipulator sql          = new SqlManipulator();

                    var convertedData = util.convertYekeQuery(dataToimport.ToList());
                    convertedData = util.convertToRealDate(convertedData);

                    var query = convertedData.AsQueryable();

                    if (this.refundRadioButton.Checked)
                    {
                        var      report = sql.refundFromFile(query, login.cityID);
                        Reporter rpt    = new Reporter(report, Convert.ToInt32(errorImages.info));
                        rpt.Show();
                    }
                    if (this.depositRadioButton.Checked)
                    {
                        sql.excelToSqlCopy(query, login.cityID);
                    }


                    this.mainForm.refreshDGV();
                }
                excelData.Clear();

                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            //  CloseProgress();
        }