private void btnLogin_Click(object sender, EventArgs e) { //Check all textbox filled or not if (fncBlank() == true) { return; } try { #region Check Valid User in Database //if (fncSoftwareExDate()==true) //{ // return; //} //Software Validation clsMain.strValidationDB = clsProc.GTRVaildationSQL(); clsMain.strValidBTDB = clsProc.GTRVaildationSQLBT(); if (fncSoftwareExDateDB() == true) { return; } System.Data.DataSet dsLogin = new System.Data.DataSet(); clsForm.prcGetLoginDetails(ref dsLogin, txtUser.Text.ToString().Trim(), txtPassword.Text.ToString().Trim()); if (dsLogin.Tables["Login"].Rows.Count == 0) { //if invalid user MessageBox.Show("Invalid user name or password", this.Text, MessageBoxButtons.OK); txtUser.Focus(); return; } else { //If valid user DataTable dt = dsLogin.Tables["Login"]; //User Id & Name clsMain.intUserId = (Int32)dt.Rows[0]["LUserId"]; clsMain.strUser = dt.Rows[0]["EmpNameCode"].ToString(); clsMain.strUserCode = dt.Rows[0]["EmpCode"].ToString(); //User SubGroupId & SubGroupName clsMain.intSGroupId = Int32.Parse(dt.Rows[0]["LSubGroupId"].ToString()); clsMain.strSGroupName = dt.Rows[0]["LSubGroupName"].ToString(); //User GroupId & GroupName clsMain.intGroupId = Int32.Parse(dt.Rows[0]["LGroupId"].ToString()); clsMain.strGroupName = dt.Rows[0]["LGroupName"].ToString(); //clsMain.intSalaryId = dt.Rows[0]["IsSalary"].ToString(); //clsMain.intAttProssId = dt.Rows[0]["IsAttPross"].ToString(); //Transaction Date clsMain.strTranDate = dt.Rows[0]["LoginDate"].ToString(); //Computer Name clsMain.strComputerName = clsProc.GTRGetComputerName(); //Computer IP Address clsMain.strIPAddress = clsProc.GTRGetIPAddress(); //Computer Mac Address clsMain.strMacAddress = "";//clsProc.GTRGetMacAddress(); } #endregion Check Valid User in Database #region User log update clsM.prcLogin(); #endregion #region Configuration clsMain.SetConfiguration(); #endregion Configuration #region call & loading next window FM.prcConfigureForm(); this.Close(); #endregion call & loading next window } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void prcImportData() { //Getting Selected File Information From List prcGetListviewData(); clsConnection clsCon = new clsConnection(); ArrayList arQuery = new ArrayList(); string sqlQuery = ""; try { using (StreamReader sr = new StreamReader(File.Open(strFileNameWithLoc, FileMode.Open))) { string line = ""; while (!string.IsNullOrEmpty(line = sr.ReadLine())) { string[] parts = line.Split(new string[] { ":" }, StringSplitOptions.None); string strTime = parts[3] + ":" + parts[4] + ":" + parts[5]; string strStNo = DateTime.Parse(parts[2].ToString()).ToString("dd:MM:yyyy").Replace(":", ""); strStNo += DateTime.Parse(strTime.ToString()).ToString("HH:mm:ss").Replace(":", ""); sqlQuery = string.Format( " INSERT INTO tblRawData ( DeviceNo, cardno, dtPunchDate, dtPunchTime, stNo, PCName, LUserId) " + " VALUES ('{0}','{1}','{2}','{3}', '{4}', '{5}', '{6}')", parts[0], parts[1], parts[2], strTime, double.Parse(strStNo), clsProc.GTRGetComputerName(), Common.Classes.clsMain.intUserId); arQuery.Add(sqlQuery); } } sqlQuery = "Update tblRawdata Set EmpId = B.EmpId, IsNew = 1 From tblRawdata AS A Inner Join tblEmp_Info As B On A.CardNo = B.CardNo Where IsNew = 0 "; arQuery.Add(sqlQuery); //Transaction with database clsCon.GTRSaveDataWithSQLCommand(arQuery); //Moving Data To Another Folder prcTransferDataFile(); MessageBox.Show("Data collection completed successfully."); } catch (Exception ex) { throw(ex); } finally { arQuery = null; clsCon = null; } }