public bool AddBillingDetails(string BillingId, string BillTo, string ContactPerson, string address, string city, string state, string country, string zip)
        {
            IRadDbTransaction objTransaction = new RadDbTransaction();
            RadDBImpl         _dbImpl        = new RadDBImpl();

            if (string.IsNullOrEmpty(BillingId) || string.IsNullOrEmpty(BillTo) || string.IsNullOrEmpty(ContactPerson))
            {
                return(false);
            }
            else
            {
                string insertBill = "INSERT INTO LKP_BILLING (BILLING_ID,BILL_TO,CONTACT_PERSON,ADDRESS,CITY,STATE,COUNTRY,ZIP) " +
                                    " VALUES ('" + BillingId.ToUpper() + "', '" + BillTo.ToUpper() + "','" + ContactPerson.ToUpper() + "','" + address.ToUpper() + "','" + city.ToUpper() + "','" + state.ToUpper() + "' , '" + country.ToUpper() + "', '" + zip + "')";



                objTransaction.AddSql(insertBill);


                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool EditBillingDetails(string BillingId, string BillTo, string ContactPerson, string address, string city, string state, string country, string zip)
        {
            RadDBImpl _dbImpl = new RadDBImpl();


            if (string.IsNullOrEmpty(BillingId) || string.IsNullOrEmpty(BillTo) || string.IsNullOrEmpty(ContactPerson))
            {
                return(false);
            }
            else
            {
                string updateBillilng = "UPDATE  LKP_BILLING SET BILL_TO = '" + BillTo.ToUpper() + "' , CONTACT_PERSON = '" + ContactPerson.ToUpper() + "' , ADDRESS = '" + address.ToUpper() + "', CITY = '" + city.ToString() + "', STATE = '" + state.ToUpper() + "', COUNTRY = '" + country.ToUpper() + "' , ZIP = '" + zip + "' WHERE BILLING_ID ='" + BillingId.ToUpper() + "'";

                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(updateBillilng);
                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool EditClient(string ClientId, string ClientName, Double Charge, string billingId, string companyId)
        {
            RadDBImpl _dbImpl = new RadDBImpl();


            if (string.IsNullOrEmpty(ClientId) || string.IsNullOrEmpty(ClientName) || string.IsNullOrEmpty(companyId))
            {
                return(false);
            }
            else
            {
                string updateClient = "UPDATE  CLIENT SET CLIENT_NAME = '" + ClientName.ToUpper() + "' , AMT_CHARGE = '" + Charge + "' , BILLING_ID = '" + billingId + "' WHERE CLIENT_ID ='" + ClientId.ToUpper() + "'";

                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(updateClient);
                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool AddClient(string ClientId, string ClientName, Double Charge, string billingId, string companyId)
        {
            IRadDbTransaction objTransaction = new RadDbTransaction();
            RadDBImpl         _dbImpl        = new RadDBImpl();

            if (string.IsNullOrEmpty(ClientId) || string.IsNullOrEmpty(ClientName) || string.IsNullOrEmpty(companyId))
            {
                return(false);
            }
            else
            {
                string insertClient = "INSERT INTO CLIENT (CLIENT_ID,CLIENT_NAME,AMT_CHARGE,BILLING_ID) " +
                                      " VALUES ('" + ClientId.ToUpper() + "', '" + ClientName.ToUpper() + "','" + Charge + "','" + billingId + "')";


                string insertClientComp = "INSERT INTO CLIENT_COMPANY (CLIENT_ID,COMPANY_ID) " +
                                          " VALUES ('" + ClientId.ToUpper() + "', '" + companyId.ToUpper() + "')";

                objTransaction.AddSql(insertClient);
                objTransaction.AddSql(insertClientComp);

                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool EditCompany(string CompanyId, string Desc, string companyNo)
        {
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(CompanyId) || string.IsNullOrEmpty(Desc))
            {
                return(false);
            }
            else
            {
                string updateComp = "UPDATE  LKP_COMPANY SET NAME = '" + Desc + "',COMPANY_NO = '" + companyNo + "' WHERE COMPANY_ID = '" + CompanyId.ToUpper() + "'";

                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(updateComp);
                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool AddCompany(string CompanyId, string Desc, string CompanyNo)
        {
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(CompanyId) || string.IsNullOrEmpty(Desc))
            {
                return(false);
            }
            else
            {
                string insertComp = "INSERT INTO LKP_COMPANY (COMPANY_ID,NAME,COMPANY_NO) " +
                                    " VALUES ('" + CompanyId.ToUpper() + "', '" + Desc.ToUpper() + "','" + CompanyNo + "')";


                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(insertComp);
                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool RegisterUser(string UserId, string password, string fname, string lname, string aabv)
        {
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(fname) || string.IsNullOrEmpty(lname) || string.IsNullOrEmpty(aabv)
                )
            {
                return(false);
            }
            else
            {
                //string sqlInsert = "insert into users (DEVICE_ID,REGKEY,USERID,PASSWORD,DEVICE_NAME,PHONE_NO,SERVICE_PROVIDER,QUESTION,ANSWER,EMAIL_ID,dt) " +
                //" VALUES ('" + deviceId + "', '" + regKey + "','" + UserId.ToUpper() + "','" + password.ToUpper() + "' , '" + deviceName  + "','" + phoneNo + "','" + service_provider + "' ,'" + question + "','" + answer + "','" + email_id + "', sysdate )";

                string insertUser = "******" +
                                    " VALUES ('" + UserId.ToUpper() + "', '" + password.ToUpper() + "','" + fname.ToUpper() + "','" + lname.ToUpper() + "' ,'" + aabv + "')";
                //  return insertUser;


                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(insertUser);
                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool AddProject(string company_id, string clientId, string Bugid, string Project_type_id, string bugdesc, string start_st, string end_dt, string user_id, string action_taken, string contact_person)
        {
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(company_id) || string.IsNullOrEmpty(Bugid) || string.IsNullOrEmpty(clientId) ||
                string.IsNullOrEmpty(Project_type_id) || string.IsNullOrEmpty(bugdesc) ||
                string.IsNullOrEmpty(start_st) || string.IsNullOrEmpty(user_id) ||
                string.IsNullOrEmpty(action_taken) || string.IsNullOrEmpty(contact_person)
                )
            {
                //return ProjectName+','+Bugid+','+Project_type_id+','+bugdesc+','+start_st+','+user_id+','+action_taken+','+contact_person;
                return(false);
            }
            else
            {
                //string sqlInsert = "insert into users (DEVICE_ID,REGKEY,USERID,PASSWORD,DEVICE_NAME,PHONE_NO,SERVICE_PROVIDER,QUESTION,ANSWER,EMAIL_ID,dt) " +
                //" VALUES ('" + deviceId + "', '" + regKey + "','" + UserId.ToUpper() + "','" + password.ToUpper() + "' , '" + deviceName  + "','" + phoneNo + "','" + service_provider + "' ,'" + question + "','" + answer + "','" + email_id + "', sysdate )";
                string   status     = string.Empty;
                string   session_id = GetNewID(Bugid);
                DateTime?end_date   = null;

                if (string.IsNullOrEmpty(end_dt))
                {
                    status = "N";
                }
                else
                {
                    status   = "Y";
                    end_date = Convert.ToDateTime(end_dt);
                }

                string insertProject = "INSERT INTO PROJECT (COMPANY_ID,CLIENT_ID,BUG_ID,PROJECT_TYPE_ID,BUG_DESC,START_DT,END_DT,USER_ID,STATUS,ACTION_TAKEN,SESSION_ID,CONTACT_PERSON) " +
                                       " VALUES ('" + company_id.ToUpper() + "', '" + clientId + "','" + Bugid.ToUpper() + "','" + Project_type_id.ToUpper() + "','" + bugdesc + "', to_date('" + Convert.ToDateTime(start_st) + "','MM/dd/yyyy hh:mi:ss am'),to_date('" + end_date + "','MM/dd/yyyy hh:mi:ss am'),'" + user_id.ToUpper() + "','" + status.ToUpper() + "','" + action_taken + "','" + session_id + "','" + contact_person + "')";

                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(insertProject);
                try
                {
                    objTransaction.ExecuteTransaction();
                    //Logging.WriteMessage("Register User Succeed");
                    return(true);
                    //return insertProject;
                }
                catch (Exception e)
                {
                    //Logging.WriteError("Register User Error ");
                    //return insertProject;
                    return(false);
                }
            }
        }
        public bool registerUser(string deviceId, string regKey, string UserId, string password, string deviceName, string phoneNo, string service_provider, string question, string answer)
        {
            if (string.IsNullOrEmpty(regKey) || string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(deviceName) || string.IsNullOrEmpty(deviceId) ||
                string.IsNullOrEmpty(question) || string.IsNullOrEmpty(answer)
                )
            {
                return(false);
            }
            else
            {
                //string sqlInsert = "insert into users (DEVICE_ID,REGKEY,USERID,PASSWORD,DEVICE_NAME,PHONE_NO,SERVICE_PROVIDER,QUESTION,ANSWER,EMAIL_ID,dt) " +
                //" VALUES ('" + deviceId + "', '" + regKey + "','" + UserId.ToUpper() + "','" + password.ToUpper() + "' , '" + deviceName  + "','" + phoneNo + "','" + service_provider + "' ,'" + question + "','" + answer + "','" + email_id + "', sysdate )";

                string insertDevice = "INSERT INTO DEVICE (DEVICE_ID,REGKEY,DEVICE_NAME,PHONE_NO,SERVICE_PROVIDER,DT) " +
                                      " VALUES ('" + deviceId + "', '" + regKey + "', '" + deviceName + "','" + phoneNo + "','" + service_provider + "' , sysdate )";

                string insertUser = "******" +
                                    " VALUES ('" + UserId + "', '" + password + "','" + question + "','" + answer + "' ,'Y', sysdate )";

                string insertDeviceUser = "******" +
                                          " VALUES ('" + deviceId + "', '" + UserId + "','Y', sysdate )";
                IRadDbTransaction objTransaction = new RadDbTransaction();
                objTransaction.AddSql(insertDevice);
                objTransaction.AddSql(insertUser);

                objTransaction.AddSql(insertDeviceUser);
                try
                {
                    objTransaction.ExecuteTransaction();
                    Logging.WriteMessage("Register User Succeed");
                    return(true);
                }
                catch (Exception e)
                {
                    Logging.WriteError("Register User Error ");
                    return(false);
                }
            }
        }
        public bool InsertLocation(string deviceId, string latitude, string longitude)
        {
            IRadDbTransaction objTransaction = new RadDbTransaction();
            bool val = false;


            if (string.IsNullOrEmpty(deviceId) || string.IsNullOrEmpty(latitude.ToString()) || string.IsNullOrEmpty(longitude.ToString()))
            {
                return(false);
            }
            else
            {
                string sqlInsert = "insert into GeoLocation (DEVICE_ID,DT,LATITUDE,LONGITUDE) VALUES ('" + deviceId + "', sysdate ," + Convert.ToDouble(latitude) + "," + Convert.ToDouble(longitude) + ")";
                try{
                    objTransaction.AddSql(sqlInsert);
                    objTransaction.ExecuteTransaction();
                    val = true;
                }
                catch { }
            }
            return(val);
        }
        public bool updateUserDevice(string deviceId, string regKey, string UserId, string oldUserId)
        {
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(regKey) || string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(deviceId)
                )
            {
                return(false);
            }
            else
            {
                string            password       = string.Empty;
                string            ques           = string.Empty;
                string            ans            = string.Empty;
                string            active         = string.Empty;
                IRadDbTransaction objTransaction = new RadDbTransaction();

                bool   isActive = isUserActive(oldUserId);
                string updSql   = "update users set active = 'N' where userId = '" + oldUserId + "'";

                string updateSql    = "update device_users set active = 'N' where device_id ='" + deviceId + "' and userId = '" + oldUserId + "'";
                bool   isUserExists = checkUserExists(UserId);
                if (isUserExists)
                {
                    string sql  = "update users set active = 'Y' where userId = '" + UserId + "'";
                    string sql1 = "update device_users set active = 'Y' where device_id ='" + deviceId + "' and userId = '" + UserId + "'";
                    objTransaction.AddSql(sql);
                    objTransaction.AddSql(sql1);
                }
                else
                {
                    string sql = "select password,question,answer,active from users where  userId = '" + oldUserId.ToUpper() + "'";

                    DataTable dt = _dbImpl.GetDataSet(sql).Tables[0];
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        password = dt.Rows[0]["password"].ToString();
                        ques     = dt.Rows[0]["question"].ToString();
                        ans      = dt.Rows[0]["answer"].ToString();
                        active   = dt.Rows[0]["active"].ToString();
                    }

                    if (!isUserExists)
                    {
                        string updateDevice = "update device set REGKEY = '" + regKey + "' where device_id = '" + deviceId + "'";

                        string insertUser = "******" +
                                            " VALUES ('" + UserId + "', '" + password + "','" + ques + "','" + ans + "' ,'Y', sysdate )";

                        string insertDeviceUser = "******" +
                                                  " VALUES ('" + deviceId + "', '" + UserId + "','Y', sysdate )";

                        objTransaction.AddSql(updateDevice);
                        objTransaction.AddSql(insertUser);
                        objTransaction.AddSql(insertDeviceUser);
                    }
                }
                objTransaction.AddSql(updSql);
                objTransaction.AddSql(updateSql);


                try
                {
                    objTransaction.ExecuteTransaction();
                    Logging.WriteMessage("Update User succeedd");
                    return(true);
                }
                catch {
                    Logging.WriteError("Update User Failed");
                    return(false);
                }
            }
        }