private void cmd_ok_Click(object sender, System.EventArgs e) { try { string tenfile = ""; tenfile = vs.Rows[vs.Row]["FIL_NM"].ToString(); if (tenfile == "Rehong_ATM.xltm" || tenfile == "Rehong_ATMNV.xltm" || tenfile == "Rehong_TienMat.xltm" || tenfile == "Rehong_TienMatNV.xltm") { Hashtable hs = new Hashtable(); hs["dateChuyenKhoan"] = ((DateTime)dt_m.Value).ToString("MM/yyyy"); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_ThongKeLuong.xltm" || tenfile == "Rehong_ThongKeLuongNV.xltm" || tenfile == "Rehong_TangCaVuot.xltm" || tenfile == "Rehong_TangCaVuotNV.xltm") { Hashtable hs = new Hashtable(); hs["strDateChoose"] = ((DateTime)dt_m.Value).ToString("MM/yyyy"); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_BangLuongNgay.xltm" || tenfile == "Rehong_BangLuongNgayNV.xltm") { Hashtable hs = new Hashtable(); hs["strDateChoose"] = ((DateTime)dt_m.Value).ToString("yyyy-MM-dd"); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else { if (vs.Row <= 0) { return; } string filename = ""; filename = PublicFunction.Path + "\\ReportsVBA\\" + vs.Rows[vs.Row]["FIL_NM"]; string where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13; where = where1 = where2 = where3 = where4 = where5 = where6 = where7 = where8 = where9 = where10 = where11 = where12 = where13 = ""; string st = "", st1 = "", st2 = "", st3 = "", st4 = ""; if (chk_CUR_DEP.Checked) { st = control1.GetWhere("FILC06AA", false); st = st.Replace("DEP_ID", "DEP_I1"); } else { st = control1.GetWhere("FILB01A", false); } if (st.Length > 255) { st1 = st.Remove(0, 255); st = st.Remove(255, st.Length - 255); if (st1.Length > 255) { st2 = st1.Remove(0, 255); st1 = st1.Remove(255, st1.Length - 255); if (st2.Length > 255) { st3 = st2.Remove(0, 255); st2 = st2.Remove(255, st2.Length - 255); if (st3.Length > 255) { st4 = st3.Remove(0, 255); st3 = st3.Remove(255, st3.Length - 255); } } } } where = st; where1 = dt_m.Text; where2 = ((DateTime)dt_dt1.Value).ToString("yyyy/MM/dd"); where3 = ((DateTime)dt_dt2.Value).ToString("yyyy/MM/dd"); where4 = dt_y.Text; where5 = cb_q.Text; where6 = ck_labour.Checked + ""; where7 = ck_vat.Checked + ""; where8 = this.Tag + ""; where9 = st1; where11 = st2; where12 = st3; //where13=st4; where13 = PublicFunction.GPS.ToString(); where10 = PublicFunction.Path; // ReportExcel.PrintExcel(filename,PublicFunction.C_ConStrForRPT,vs.Rows[vs.Row][PublicFunction.L_Lag]+"","", // PublicFunction.L_Lag,where,where1,where2,where3,where4,where5,where6,where7,where8,where9,where10,PublicFunction.A_UserID); //khoa bao bieu string keyD = ""; string ktype = ""; int iphut = 0; SqlConnection SqlCon1 = new SqlConnection(PublicFunction.C_con.ConnectionString); SqlCon1.Open(); Func.RecordSet rsK = new Func.RecordSet("Select * from GP_KEY", SqlCon1); if (rsK.rows > 0) { ktype = rsK.record(0, "TYP_MN"); keyD = PublicFunction.encode(rsK.record(0, "COL_DT"), ""); iphut = T_String.IsNullTo0(rsK.record(0, "COL_MN")); } if (DateTime.Now >= DateTime.Parse(keyD) && ktype.ToUpper() == "RE") { MessageBox.Show("Office DLL was error"); return; } //end ReportExcel.PrintExcel(filename, PublicFunction.C_ConStrForRPT, vs.Rows[vs.Row][PublicFunction.L_Lag] + "", "", PublicFunction.L_Lag, where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13, PublicFunction.A_UserID); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void cmd_ok_Click(object sender, System.EventArgs e) { try { string tenfile = ""; tenfile = vs.Rows[vs.Row]["FIL_NM"].ToString(); if (tenfile == "fvn_Test01.xltm") { Hashtable hs = new Hashtable(); hs["dateFrom"] = ((DateTime)dt_dt1.Value).ToString("yyyy-MM-dd"); hs["dateTo"] = ((DateTime)dt_dt2.Value).ToString("yyyy-MM-dd"); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_DanhSachTangCa.xltm") { DateTime dateTimeFrom = Convert.ToDateTime(dt_dt1.Text); DateTime dateTimeTo = Convert.ToDateTime(dt_dt2.Text); object dtResult = dateTimeTo.Subtract(dateTimeFrom); Hashtable hs = new Hashtable(); hs["strBoPhan"] = control1.CB_DEP.Text.ToString(); //bophan; hs["dateTimeFrom"] = dateTimeFrom.ToString("HH:mm"); //time from; hs["dateTimeTo"] = dateTimeTo.ToString("HH:mm"); //time to; hs["WorkHour"] = ((System.TimeSpan)(((TimeSpan)dtResult))).TotalHours.ToString(); ReportExcel2.TemplateToExcel(tenfile, hs); } else if (tenfile == "Rehong_TheNhanVien.xltm" || tenfile == "Rehong_TheNhanVienNV.xltm") { Hashtable hs = new Hashtable(); hs["strWhere"] = BuildWhereQuery(); ReportExcel2.TemplateToExcel(tenfile, hs); } else { if (vs.Row <= 0) { return; } string filename = ""; string st = "", st1 = "", st2 = "", st3 = "", st4 = ""; filename = PublicFunction.Path + "\\ReportsVBA\\" + vs.Rows[vs.Row]["FIL_NM"]; string where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13; where = where1 = where2 = where3 = where4 = where5 = where6 = where7 = where8 = where9 = where10 = where11 = where12 = where13 = ""; if (chk_CUR_DEP.Checked) { st = control1.GetWhere("m", false); st = st.Replace("DEP_ID", "DEP_I1"); } else { st = control1.GetWhere("FILB01A", false); } if (st.Length > 255) { st1 = st.Remove(0, 255); st = st.Remove(255, st.Length - 255); if (st1.Length > 255) { st2 = st1.Remove(0, 255); st1 = st1.Remove(255, st1.Length - 255); if (st2.Length > 255) { st3 = st2.Remove(0, 255); st2 = st2.Remove(255, st2.Length - 255); if (st3.Length > 255) { st4 = st3.Remove(0, 255); st3 = st3.Remove(255, st3.Length - 255); } } } } where = st; where1 = dt_m.Text; where2 = ((DateTime)dt_dt1.Value).ToString("yyyy/MM/dd"); where3 = ((DateTime)dt_dt2.Value).ToString("yyyy/MM/dd"); where4 = dt_y.Text; where5 = cb_q.Text; where6 = ck_labour.Checked + ""; where7 = ck_vat.Checked + ""; where8 = this.Tag + ""; where9 = st1; where11 = st2; where12 = st3; //where13=st4; where13 = PublicFunction.GPS.ToString(); where10 = PublicFunction.Path; string xmlname = vs.Rows[vs.Row]["FIL_NM"] + ""; //Thu sua lam the bang C1Report if (xmlname.Substring(xmlname.Length - 3, 3) == "xml") { filename = PublicFunction.Path + "\\Reports\\" + vs.Rows[vs.Row]["FIL_NM"]; frmPrintCard dlg = new frmPrintCard(st, filename, xmlname.Substring(0, xmlname.Length - 4)); dlg.Tag = this.Tag; dlg.ShowDialog(); return; } //end Thu // rp.PrintExcel(filename,PublicFunction.C_ConStrForRPT,vs.Rows[vs.Row][PublicFunction.L_Lag]+"","", // PublicFunction.L_Lag,where,where1,where2,where3,where4,where5,where6,where7,where8,where9,where10,PublicFunction.A_UserID); //khoa bao bieu string keyD = ""; string ktype = ""; int iphut = 0; SqlConnection SqlCon1 = new SqlConnection(PublicFunction.C_con.ConnectionString); SqlCon1.Open(); Func.RecordSet rsK = new Func.RecordSet("Select * from GP_KEY", SqlCon1); if (rsK.rows > 0) { ktype = rsK.record(0, "TYP_MN"); keyD = PublicFunction.encode(rsK.record(0, "COL_DT"), ""); iphut = T_String.IsNullTo0(rsK.record(0, "COL_MN")); } if (DateTime.Now >= DateTime.Parse(keyD) && ktype.ToUpper() == "RE") { MessageBox.Show("Office DLL was error"); return; } //end ReportExcel.PrintExcel(filename, PublicFunction.C_ConStrForRPT, vs.Rows[vs.Row][PublicFunction.L_Lag] + "", "", PublicFunction.L_Lag, where, where1, where2, where3, where4, where5, where6, where7, where8, where9, where10, where11, where12, where13, PublicFunction.A_UserID); } } catch (Exception ex) {} }