private void prcShowReport() { dsDetails = new DataSet(); ArrayList arQuery = new ArrayList(); clsConnection clsCon = new clsConnection(); try { DataSourceName = "DataSet1"; FormCaption = "Transection Log..."; string EmpId = "0", UserId = "0", Type = "=ALL="; EmpId = gridEmployeeID.ActiveRow.Cells["EmpId"].Value.ToString(); UserId = gridList.ActiveRow.Cells["LUserId"].Value.ToString(); Type = gridType.ActiveRow.Cells["Type"].Value.ToString(); if (optCriteria.Value.ToString().ToUpper() == "Employee".ToUpper()) { rptQuery = "Exec rptTranLog '" + UserId + "',1, '" + EmpId + "','" + Type + "','Employee','" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'"; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, rptQuery); } else if (optCriteria.Value.ToString().ToUpper() == "User".ToUpper()) { rptQuery = "Exec rptTranLog '" + UserId + "',1, '" + EmpId + "','" + Type + "','User','" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'"; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, rptQuery); } if (dsDetails.Tables[0].Rows.Count == 0) { MessageBox.Show("Data Not Found"); return; } clsReport.strReportPathMain = ReportPath; clsReport.strQueryMain = rptQuery; clsReport.strDSNMain = DataSourceName; FM.prcShowReport(FormCaption); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { rptQuery = null; DataSourceName = null; DataSourceName = null; ReportPath = null; clsCon = null; } }
private void btnPrevew_Click(object sender, EventArgs e) { dsDetails = new DataSet(); ArrayList arQuery = new ArrayList(); GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection(); string sqlQuery = ""; string ReportPath = ""; string SQLQuery = "", Band = "=All=", strFloor = "", strLine = ""; Int32 DeptId = 0, EmpId = 0; if (optrptFormat.Value.ToString().ToUpper() == "General".ToUpper()) { //Collecting Parameter Value if (optCriteria.Value.ToString().ToUpper() == "Department".ToUpper()) { DeptId = Int32.Parse(gridSect.ActiveRow.Cells["SectId"].Value.ToString()); strFloor = cboFloor.Text.ToString(); strLine = cboLine.Text.ToString(); ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCardB.rdlc"; SQLQuery = "Exec rptJobCardB3 " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId.ToString() + ", '" + strFloor + "','" + Band + "', " + EmpId + " "; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, SQLQuery); clsMain.strReportName = "Job Card"; if (dsDetails.Tables[0].Rows.Count == 0) { MessageBox.Show("Data Not Found"); return; } } else if (optCriteria.Value.ToString().ToUpper() == "Employee".ToUpper()) { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridEmployee.Rows) { if (row.Cells["EmpId"].Text.ToString().Length != 0 && row.Cells["isCheck"].Value.ToString() == "1") { EmpId = Int32.Parse(row.Cells["empid"].Text.ToString()); ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCardB.rdlc"; SQLQuery = "Exec rptJobCardB3 " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId.ToString() + ", '','" + Band + "', " + EmpId + " "; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, SQLQuery); clsMain.strReportName = "Job Card"; } } } else if (optCriteria.Value.ToString().ToUpper() == "Line".ToUpper()) { Band = gridBand.ActiveRow.Cells["varName"].Value.ToString(); ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCardB.rdlc"; SQLQuery = "Exec rptJobCardB3 " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId.ToString() + ", '" + strFloor + "','" + Band + "', " + EmpId + " "; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, SQLQuery); clsMain.strReportName = "Job Card"; if (dsDetails.Tables[0].Rows.Count == 0) { MessageBox.Show("Data Not Found"); return; } } } else { if (optCriteria.Value.ToString().ToUpper() == "Department".ToUpper()) { DeptId = Int32.Parse(gridSect.ActiveRow.Cells["SectId"].Value.ToString()); strFloor = cboFloor.Text.ToString(); strLine = cboLine.Text.ToString(); ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCardDetails.rdlc"; SQLQuery = "Exec rptJobCardMonthlyProcess " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId.ToString() + ", '" + strFloor + "','" + strLine + "', " + EmpId + ""; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, SQLQuery); clsMain.strReportName = "Job Card Details"; if (dsDetails.Tables[0].Rows.Count == 0) { MessageBox.Show("Data Not Found"); return; } } else if (optCriteria.Value.ToString().ToUpper() == "Employee".ToUpper()) { EmpId = Int32.Parse(gridEmployee.ActiveRow.Cells["EmpId"].Value.ToString()); ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCardDetails.rdlc"; SQLQuery = "Exec rptJobCardMonthlyProcess " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId.ToString() + ", '" + strFloor + "','" + strLine + "', " + EmpId + ""; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, SQLQuery); clsMain.strReportName = "Job Card Details"; if (dsDetails.Tables[0].Rows.Count == 0) { MessageBox.Show("Data Not Found"); return; } } else if (optCriteria.Value.ToString().ToUpper() == "Line".ToUpper()) { Band = gridBand.ActiveRow.Cells["varName"].Value.ToString(); ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCardB.rdlc"; SQLQuery = "Exec rptJobCardB3 " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId.ToString() + ", '" + strFloor + "','" + Band + "', " + EmpId + " "; clsCon.GTRFillDatasetWithSQLCommand(ref dsDetails, SQLQuery); clsMain.strReportName = "Job Card"; if (dsDetails.Tables[0].Rows.Count == 0) { MessageBox.Show("Data Not Found"); return; } } } string DataSourceName = "DataSet1"; string FormCaption = "Report :: Job Card ..."; //GTRLibrary.clsReport.strReportPathMain = ReportPath; //GTRLibrary.clsReport.strQueryMain = SQLQuery; //GTRLibrary.clsReport.strDSNMain = DataSourceName; //clsMain.strExtension = optFormat.Value.ToString(); //clsMain.strFormat = optFormat.Text.ToString(); //FM.prcShowReport(FormCaption); clsReport.strReportPathMain = ReportPath; clsReport.dsReport = dsDetails; clsReport.strDSNMain = DataSourceName; Common.Classes.clsMain.strExtension = optFormat.Value.ToString(); Common.Classes.clsMain.strFormat = optFormat.Text.ToString(); FM.prcShowReport(FormCaption); //clsReport.strReportPathMain = ReportPath; //clsReport.strQueryMain = SQLQuery; //clsReport.strDSNMain = DataSourceName; //clsMain.strExtension = optFormat.Value.ToString(); //clsMain.strFormat = optFormat.Text.ToString(); }
private void btnSave_Click(object sender, EventArgs e) { if (fncBlank()) { return; } ArrayList arQuery = new ArrayList(); clsConnection clsCon = new clsConnection(); string sqlQuery = ""; Int32 NewId = 0; try { //Get Shift Id string ShiftId = gridList.ActiveRow.Cells["ShiftId"].Value.ToString(); //Get Sect Id string SectId = gridSec.ActiveRow.Cells["SectId"].Value.ToString(); string Band = gridBand.ActiveRow.Cells["VarName"].Value.ToString(); if (chkSave.Checked == true) { //Delete Existing Data if (optCriteria.Value.ToString().ToUpper() == "All".ToUpper()) { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "'"; arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Section".ToUpper()) { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId in (Select EmpId from tblEmp_Info Where SectId=" + SectId + ")"; arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Band".ToUpper()) { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId in (Select EmpId from tblEmp_Info Where Band='" + Band + "')"; arQuery.Add(sqlQuery); } else { foreach (UltraGridRow row in this.gridEmp.Rows) { if (row.Cells["Chk"].Value.ToString() == "1") { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId = " + row.Cells["EmpId"].Text.ToString() + " "; arQuery.Add(sqlQuery); } } } //Loop Date wise for (DateTime dtStart = dtDateFrom.DateTime; dtDateTo.DateTime >= dtStart; dtStart = dtStart.AddDays(1)) { //Insert Data Based On Criteria if (optCriteria.Value.ToString().ToUpper() == "All".ToUpper()) { //Insert Data sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + " Where ComID = " + Common.Classes.clsMain.intComId + " And IsInactive = 0"; arQuery.Add(sqlQuery); //Update Data sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And IsInactive = 0"; arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Section".ToUpper()) { ////Delete Existing Data //sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and SectId ="+SectId+""; //arQuery.Add(sqlQuery); sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + " Where ComID = " + Common.Classes.clsMain.intComId + " and " + " SectId = " + SectId + " And IsInactive = 0"; arQuery.Add(sqlQuery); //Update Data sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And SectId = " + SectId + " And IsInactive = 0"; arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Band".ToUpper()) { ////Delete Existing Data //sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and SectId ="+SectId+""; //arQuery.Add(sqlQuery); sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + " Where ComID = " + Common.Classes.clsMain.intComId + " and " + " Band = '" + Band + "' And IsInactive = 0"; arQuery.Add(sqlQuery); //Update Data sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And Band = '" + Band + "' And IsInactive = 0"; arQuery.Add(sqlQuery); } else { foreach (UltraGridRow row in this.gridEmp.Rows) { if (row.Cells["Chk"].Value.ToString() == "1") { sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Values(" + Common.Classes.clsMain.intComId + ", " + row.Cells["EmpId"].Text.ToString() + ", '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + ")"; arQuery.Add(sqlQuery); //Update Data sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And EmpID = " + row.Cells["EmpId"].Text.ToString() + " And IsInactive = 0"; arQuery.Add(sqlQuery); } } } } clsCon.GTRSaveDataWithSQLCommand(arQuery); MessageBox.Show("Data Updated Successfully."); RowUncheck(); } //Checkbox uncheck Shift Data not update Employee information else { //Delete Existing Data if (optCriteria.Value.ToString().ToUpper() == "All".ToUpper()) { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "'"; arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Section".ToUpper()) { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId in (Select EmpId from tblEmp_Info Where SectId=" + SectId + ")"; arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Band".ToUpper()) { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId in (Select EmpId from tblEmp_Info Where Band='" + Band + "')"; arQuery.Add(sqlQuery); } else { foreach (UltraGridRow row in this.gridEmp.Rows) { if (row.Cells["Chk"].Value.ToString() == "1") { sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId = " + row.Cells["EmpId"].Text.ToString() + " "; arQuery.Add(sqlQuery); } } } //Loop Date wise for (DateTime dtStart = dtDateFrom.DateTime; dtDateTo.DateTime >= dtStart; dtStart = dtStart.AddDays(1)) { //Insert Data Based On Criteria if (optCriteria.Value.ToString().ToUpper() == "All".ToUpper()) { //Insert Data sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + " Where ComID = " + Common.Classes.clsMain.intComId + " And IsInactive = 0"; arQuery.Add(sqlQuery); //Update Data //sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And IsInactive = 0"; //arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Section".ToUpper()) { ////Delete Existing Data //sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and SectId ="+SectId+""; //arQuery.Add(sqlQuery); sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + " Where ComID = " + Common.Classes.clsMain.intComId + " and " + " SectId = " + SectId + " And IsInactive = 0"; arQuery.Add(sqlQuery); //Update Data //sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And SectId = " + SectId + " And IsInactive = 0"; //arQuery.Add(sqlQuery); } else if (optCriteria.Value.ToString().ToUpper() == "Band".ToUpper()) { ////Delete Existing Data //sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and SectId ="+SectId+""; //arQuery.Add(sqlQuery); sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + " Where ComID = " + Common.Classes.clsMain.intComId + " and " + " Band = '" + Band + "' And IsInactive = 0"; arQuery.Add(sqlQuery); //Update Data //sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And Band = '" + Band + "' And IsInactive = 0"; //arQuery.Add(sqlQuery); } else { foreach (UltraGridRow row in this.gridEmp.Rows) { if (row.Cells["Chk"].Value.ToString() == "1") { sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Values(" + Common.Classes.clsMain.intComId + ", " + row.Cells["EmpId"].Text.ToString() + ", '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + ")"; arQuery.Add(sqlQuery); //Update Data //sqlQuery = "Update tblEmp_Info Set ShiftId = " + ShiftId + " Where ComID = " + Common.Classes.clsMain.intComId + " And EmpID = " + row.Cells["EmpId"].Text.ToString() + " And IsInactive = 0"; //arQuery.Add(sqlQuery); } } } } clsCon.GTRSaveDataWithSQLCommand(arQuery); MessageBox.Show("Data Updated Successfully."); RowUncheck(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { arQuery = null; clsCon = null; } }
private void btnPrevew_Click(object sender, EventArgs e) { string ReportPath = ""; string SQLQuery = ""; Int32 DeptId = 0; if (optSection.Value.ToString().ToUpper() == "Grid".ToUpper()) { DeptId = Int32.Parse(gridSect.ActiveRow.Cells["Deptid"].Value.ToString()); } else { DeptId = Int32.Parse(Tree.SelectedNode.ImageKey.ToString()); } if (optInv.Value.ToString().ToUpper() == "Department".ToUpper()) { ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCard.rdlc"; SQLQuery = "Exec rptJobCard " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "'," + DeptId + ", '" + cboFloor.Text + "','" + cboLine.Text + "', 0 "; } else { ReportPath = Common.Classes.clsMain.AppPath + @"\Attendence\Reports\rptJobCard.rdlc"; SQLQuery = "Exec rptJobCard " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "', '" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "',0, '" + cboFloor.Text + "','" + cboLine.Text + "'," + gridEmployee.ActiveRow.Cells["Empid"].Value + " "; } string DataSourceName = "DataSet1"; string FormCaption = "Report :: Job Card ..."; clsReport.strReportPathMain = ReportPath; clsReport.dsReport = dsDetails; clsReport.strDSNMain = DataSourceName; Common.Classes.clsMain.strExtension = optFormat.Value.ToString(); Common.Classes.clsMain.strFormat = optFormat.Text.ToString(); FM.prcShowReport(FormCaption); //GTRLibrary.clsReport.strReportPathMain = ReportPath; //GTRLibrary.clsReport.strQueryMain = SQLQuery; //GTRLibrary.clsReport.strDSNMain = DataSourceName; //FM.prcShowReport(FormCaption); }
private void btnSave_Click(object sender, EventArgs e) { if (fncBlank()) { return; } ArrayList arQuery = new ArrayList(); clsConnection clsCon = new clsConnection(); string sqlQuery = "", sqlQuery1 = "", sqlQuery2 = "", sqlQuery3 = ""; Int32 NewId = 0; DateTime lastDay = dtDateFrom.DateTime; lastDay = lastDay.AddDays(-2); dtDateR.Value = lastDay; try { //Get Shift Id string ShiftId = gridList.ActiveRow.Cells["ShiftId"].Value.ToString(); //Get Shift Rotation Id string ShiftIdR = gridListRotation.ActiveRow.Cells["ShiftId"].Value.ToString(); //Get Sect Id //string SectId = gridSec.ActiveRow.Cells["SectId"].Value.ToString(); //string Band = gridBand.ActiveRow.Cells["VarName"].Value.ToString(); //Delete Existing Data if (optCriteria.Value.ToString().ToUpper() == "All".ToUpper()) { //sqlQuery = "Delete From tblEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and ShiftID = '" + ShiftId.ToString() + "'"; //arQuery.Add(sqlQuery); //sqlQuery3 = "delete tbltempEmp_Shift"; //arQuery.Add(sqlQuery3); sqlQuery1 = "Exec prcShiftRotation " + Common.Classes.clsMain.intComId + ",'" + clsProc.GTRDate(dtDateFrom.Value.ToString()) + "','" + clsProc.GTRDate(dtDateTo.Value.ToString()) + "','" + clsProc.GTRDate(dtDateR.Value.ToString()) + "','" + ShiftId.ToString() + "', '" + ShiftIdR.ToString() + "'"; arQuery.Add(sqlQuery1); } //else if (optCriteria.Value.ToString().ToUpper() == "Section".ToUpper()) //{ // sqlQuery = "Delete From tbltempEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + // " and EmpId in (Select EmpId from tblEmp_Info Where SectId=" + SectId + ")"; // arQuery.Add(sqlQuery); //} //else if (optCriteria.Value.ToString().ToUpper() == "Band".ToUpper()) //{ // sqlQuery = "Delete From tbltempEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + // " and EmpId in (Select EmpId from tblEmp_Info Where Band='" + Band + "')"; // arQuery.Add(sqlQuery); //} else { foreach (UltraGridRow row in this.gridEmp.Rows) { if (row.Cells["Chk"].Value.ToString() == "1") { sqlQuery = "Delete From tbltempEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' " + " and EmpId = " + row.Cells["EmpId"].Text.ToString() + " "; arQuery.Add(sqlQuery); } } } //Loop Date wise for (DateTime dtStart = dtDateFrom.DateTime; dtDateTo.DateTime >= dtStart; dtStart = dtStart.AddDays(1)) { //Insert Data Based On Criteria if (optCriteria.Value.ToString().ToUpper() == "All".ToUpper()) { //Insert Data sqlQuery = "Insert Into tblEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "',ShiftIdR,'" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tbltempEmp_Shift " + " Where ComID = " + Common.Classes.clsMain.intComId + ""; arQuery.Add(sqlQuery); //Update Data sqlQuery2 = "Update E Set E.ShiftId = T.ShiftIdR from tblEmp_Info E,tbltempEmp_Shift T Where E.EmpID = T.EmpID and T.ComID = " + Common.Classes.clsMain.intComId + ""; arQuery.Add(sqlQuery2); } //else if (optCriteria.Value.ToString().ToUpper() == "Section".ToUpper()) //{ // ////Delete Existing Data // //sqlQuery = "Delete From tbltempEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and SectId ="+SectId+""; // //arQuery.Add(sqlQuery); // sqlQuery = "Insert Into tbltempEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + // " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + // " Where ComID = " + Common.Classes.clsMain.intComId + " and " + // " SectId = " + SectId + " And IsInactive = 0"; // arQuery.Add(sqlQuery); //} //else if (optCriteria.Value.ToString().ToUpper() == "Band".ToUpper()) //{ // ////Delete Existing Data // //sqlQuery = "Delete From tbltempEmp_Shift Where ComId = " + Common.Classes.clsMain.intComId + " And dtDate Between '" + clsProc.GTRDate(dtDateFrom.DateTime.ToString()) + "' and '" + clsProc.GTRDate(dtDateTo.DateTime.ToString()) + "' and SectId ="+SectId+""; // //arQuery.Add(sqlQuery); // sqlQuery = "Insert Into tbltempEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + // " Select ComId, EmpId, '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + " from tblEmp_Info " + // " Where ComID = " + Common.Classes.clsMain.intComId + " and " + // " Band = '" + Band + "' And IsInactive = 0"; // arQuery.Add(sqlQuery); //} else { foreach (UltraGridRow row in this.gridEmp.Rows) { if (row.Cells["Chk"].Value.ToString() == "1") { sqlQuery = "Insert Into tbltempEmp_Shift (ComId, EmpId, dtDate, ShiftId, PCName, LUserId) " + " Values(" + Common.Classes.clsMain.intComId + ", " + row.Cells["EmpId"].Text.ToString() + ", '" + clsProc.GTRDate(dtStart.Date.ToString()) + "', " + ShiftId + ", '" + Common.Classes.clsMain.strComputerName + "', " + Common.Classes.clsMain.intUserId + ")"; arQuery.Add(sqlQuery); } } } } sqlQuery = "Insert Into tblUser_Trans_Log (LUserId, formName, tranStatement, PCName,tranType)" + " Values (" + Common.Classes.clsMain.intUserId + ", '" + this.Name.ToString() + "','" + sqlQuery.Replace("'", "|") + "','" + Common.Classes.clsMain.strComputerName + "','Input')"; arQuery.Add(sqlQuery); clsCon.GTRSaveDataWithSQLCommand(arQuery); MessageBox.Show("Data Updated Successfully."); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { arQuery = null; clsCon = null; } }