Esempio n. 1
0
 private void gridView1_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         DataRow dr = gridView1.GetFocusedDataRow();
         if (dr != null)
         {
             frmInputParam frm = new frmInputParam(_core, Static.ToStr(dr["ReportFullName"]));
             frm.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         colindex.Clear();
         MessageBox.Show("Тайлангын формат таарахгүй байна: " + ex.Message);
     }
 }
Esempio n. 2
0
 private void gridView2_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         DataRow           dr           = gridView2.GetFocusedDataRow();
         Excel.Application xlsm         = new Excel.Application();
         Excel.Workbook    xlsWorkBook  = xlsm.Workbooks.Open(@Convert.ToString(dr["ReportFullName"]), 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
         Excel.Worksheet   xlsWorkSheet = xlsWorkBook.Worksheets[1];
         for (int i = 1; i <= xlsWorkSheet.UsedRange.Columns.Count; i++)
         {
             if (!colindex.ContainsKey(xlsWorkSheet.Cells[1, i].Value.ToString()))
             {
                 colindex.Add(xlsWorkSheet.Cells[1, i].Value.ToString(), i);
             }
             else
             {
                 colindex.Clear();
                 MessageBox.Show(string.Format("{0} талбар өмнө нь үүссэн байна.", xlsWorkSheet.Cells[1, i].Value));
             }
         }
         frmInputParam frm = new frmInputParam(_core, xlsWorkSheet.Name);
         frm.ShowDialog();
         int rowindex = 2;
         if (frm.ReportData != null)
         {
             foreach (DataRow row in frm.ReportData.Rows)
             {
                 foreach (DictionaryEntry fieldname in colindex)
                 {
                     xlsWorkSheet.Cells[rowindex, Convert.ToInt32(fieldname.Value)].Value = row[fieldname.Key.ToString()];
                 }
                 rowindex++;
             }
             string path = string.Format("{0}\\Reports{1}.xlsm", _core.ReportPathOut, DateTime.Now.Ticks.ToString());
             xlsWorkBook.SaveCopyAs(path);
             System.Diagnostics.Process.Start(path);
             colindex.Clear();
         }
     }
     catch (Exception ex)
     {
         colindex.Clear();
         MessageBox.Show("Тайлангын формат таарахгүй байна: " + ex.Message);
     }
 }