예제 #1
0
        private void prcSaveData(DataSet ds)
        {
            clsConnection clsCon   = new clsConnection();
            ArrayList     arQuery  = new ArrayList();
            string        sqlQuery = "";

            try
            {
                // Clear Existing Data
                string query = "Truncate Table tblDN_xls";
                clsCon.GTRSaveDataWithSQLCommand(query);

                txtProcessNo.Text = DateTime.Now.ToString("yyyyMMddHHmmss");
                string dtProcess = DateTime.Today.ToString("dd-MMM-yyyy");

                //Generating Insert Statement Row By Row
                for (int i = 2; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i][0].ToString().Replace("'", "").Length > 0)
                    {
                        sqlQuery = "Insert Into tblDN_xls (ComId, xlsFileName, dtProcess, EntryNo, " +
                                   " empid,dtPunchDate,TimeIn,TimeOut,OTHour,Status,Remarks,PCName,LUserId) " +
                                   " Values(" + Common.Classes.clsMain.intComId + "," +
                                   " '" + txtFileName.Tag.ToString() + "', " +
                                   " '" + dtProcess + "'," +
                                   " '" + txtProcessNo.Text.ToString() + "'," +

                                   " '" + ds.Tables[0].Rows[i][0].ToString().Replace("'", "") + "', " +
                                   " '" + clsProc.GTRDate(ds.Tables[0].Rows[i][1].ToString().Replace("'", "")) + "', " +
                                   " '" + clsProc.GTRTime(ds.Tables[0].Rows[i][2].ToString().Replace("'", "")) + "', " +
                                   " '" + clsProc.GTRTime(ds.Tables[0].Rows[i][3].ToString().Replace("'", "")) + "', " +
                                   " '" + clsProc.GTRTime(ds.Tables[0].Rows[i][4].ToString().Replace("'", "")) + "', " +
                                   " '" + ds.Tables[0].Rows[i][5].ToString().Replace("'", "") + "', " +
                                   " '" + ds.Tables[0].Rows[i][14].ToString().Replace("'", "") + "', " +
                                   " '" + Common.Classes.clsMain.strComputerName + "', " +
                                   // " '" + ds.Tables[0].Rows[i][5].ToString().Replace("'", "").Replace("NA", "0").Replace("N/A", "0") + "', '" +
                                   " '" + Common.Classes.clsMain.intUserId + "')";

                        arQuery.Add(sqlQuery);
                    }
                    else
                    {
                        break;
                    }
                }


                sqlQuery = " exec  [prcProcessAttendFix] " + Common.Classes.clsMain.intComId + ", '" +
                           clsProc.GTRDate(dtInputDate.Value.ToString()) + "' ";
                arQuery.Add(sqlQuery);

                //Transaction with database server
                clsCon.GTRSaveDataWithSQLCommand(arQuery);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                arQuery = null;
                clsCon  = null;
            }
        }