public bool checkUserExists(string userId)
        {
            bool      val     = false;
            RadDBImpl _dbImpl = new RadDBImpl();
            string    sql     = "select userId from users where userid = '" + userId.ToUpper() + "'";

            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    if (reader.Read())
                    {
                        val = true;
                    }
                    else
                    {
                        val = false;
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }
            return(val);
        }
        public bool checkRegKey(string regKey, string deviceId)
        {
            string    sql     = "select regkey from device where regkey= '" + regKey + "' and device_id = '" + deviceId + "'";
            RadDBImpl _dbImpl = new RadDBImpl();
            bool      val     = false;

            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    if (reader.Read())
                    {
                        val = true;
                    }
                    else
                    {
                        val = false;
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }
            return(val);
        }
        public string checkDeviceExists(string deviceId)
        {
            RadDBImpl _dbImpl = new RadDBImpl();

            string val = "false";

            if (string.IsNullOrEmpty(deviceId))
            {
                return("false");
            }
            else
            {
                string      sql = "select device_id from device where device_id = '" + deviceId + "'";
                IDataReader rd  = _dbImpl.GetDataReader(sql);
                try
                {
                    if (rd.Read())
                    {
                        val = "true";
                    }
                    else
                    {
                        val = "false";
                    }
                }
                catch { }
                finally { rd.Close(); }
            }

            return(val);
        }
        public string GetUserId(string deviceId)
        {
            string    returnVal = string.Empty;
            RadDBImpl _dbImpl   = new RadDBImpl();
            string    sql       = "select userId from device_users where device_id = '" + deviceId + "' and active = 'Y'";

            if (string.IsNullOrEmpty(deviceId))
            {
                return(string.Empty);
            }
            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    while (reader.Read())
                    {
                        returnVal = reader["userId"].ToString();
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }


            return(returnVal);
        }
        public bool isUserActive(string userId)
        {
            RadDBImpl _dbImpl = new RadDBImpl();
            bool      val     = false;
            string    sql     = "select userId from users where userid = '" + userId.ToUpper() + "' and ACTIVE = 'Y'";

            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    if (reader.Read())
                    {
                        val = true;
                    }
                    else
                    {
                        val = false;
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }
            return(val);
        }
        public string InsertImage(string deviceId, string byteStream, string toAddress)
        {
            string inserted = string.Empty;

            byte[] byteArray = System.Convert.FromBase64String(byteStream);

            RadDBImpl _dbImpl = new RadDBImpl();

            //string insertImage = "INSERT INTO DEVICE (device_id,dt,image_name) " +
            //                      " VALUES ('" + deviceId + "', sysdate , '" + byteArray + "')";

            //objTransaction.AddSql(insertImage);
            //objTransaction.ExecuteTransaction();

            if (string.IsNullOrEmpty(deviceId) || string.IsNullOrEmpty(byteStream.ToString()))
            {
                return("error");
            }
            else
            {
                inserted = _dbImpl.ExecuteBlog(deviceId, byteStream);
                string subject   = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["ImageEmailSubject"]);
                string EmailText = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["ImageEmailText"]);

                sendMail(deviceId, byteStream, toAddress, subject, EmailText, true);
                return(inserted);
            }
            //conn.CloseConnection();
        }
        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 string GetRegistrationKey(string deviceId)
        {
            string    returnVal = string.Empty;
            RadDBImpl _dbImpl   = new RadDBImpl();
            string    sql       = "select REGKEY from DEVICE where device_id = '" + deviceId + "'";

            if (string.IsNullOrEmpty(deviceId))
            {
                return(string.Empty);
            }
            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    while (reader.Read())
                    {
                        returnVal = reader["REGKEY"].ToString();
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }

            return(returnVal);
        }
        public string GetCompany(string companyId)
        {
            string    sql     = string.Empty;
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(companyId))
            {
                sql = "select company_id , name,company_no from lkp_company";
            }
            else
            {
                sql = "select company_id,name ,company_no from lkp_company where company_id = '" + companyId.ToUpper() + "'";
            }

            DataTable dt = _dbImpl.GetDataSet(sql).Tables[0];

            foreach (DataRow rw in dt.Rows)
            {
                string company_id = rw["company_id"].ToString();
                rw["company_id"] = company_id;
                string name = rw["name"].ToString();
                rw["name"] = name;
                string company_no = rw["company_no"].ToString();
                rw["company_no"] = company_no;
            }

            return(GetJson(dt));
        }
        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 checkUser(string UserId, string password)
        {
            RadDBImpl _dbImpl = new RadDBImpl();
            bool      val     = false;
            string    sql     = "select USERID from users where USERID = '" + UserId.ToUpper() + "' and PASSWORD = '******' AND ACTIVE = 'Y' ";

            if (string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(password))
            {
                return(false);
            }
            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    if (reader.Read())
                    {
                        val = true;
                    }
                    else
                    {
                        val = false;
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }
            Logging.WriteMessage("Check User" + UserId.ToUpper() + " - " + val);

            return(val);
        }
        public byte[] getImageByteArray(string deviceId)
        {
            string sql = "select dt,IMAGE_NAME from image where device_id = '" + deviceId + "' order by dt desc";

            byte[]    byteArray = null;
            RadDBImpl _dbImpl   = new RadDBImpl();

            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    while (reader.Read())
                    {
                        byteArray = (Byte[])reader["IMAGE_NAME"];
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }

            return(byteArray);
        }
        public string GetDeviceId(string userId)
        {
            RadDBImpl _dbImpl   = new RadDBImpl();
            string    returnVal = string.Empty;
            string    sql       = "select device_id from DEVICE_USERS where userId = '" + userId + "' AND ACTIVE = 'Y' ";

            if (string.IsNullOrEmpty(userId))
            {
                return(string.Empty);
            }

            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    while (reader.Read())
                    {
                        returnVal = reader["device_id"].ToString();
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }
            return(returnVal);
        }
        public string GetCompanyClients(string companyId)
        {
            string    sql     = string.Empty;
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(companyId))
            {
                sql = "select A.CLIENT_ID,CLIENT_NAME from CLIENT A,CLIENT_COMPANY B WHERE A.CLIENT_ID = B.CLIENT_ID";
            }
            else
            {
                sql = "select A.CLIENT_ID,CLIENT_NAME from CLIENT A,CLIENT_COMPANY B WHERE A.CLIENT_ID = B.CLIENT_ID AND  COMPANY_ID = '" + companyId.ToUpper() + "'";
            }

            DataTable dt = _dbImpl.GetDataSet(sql).Tables[0];


            foreach (DataRow rw in dt.Rows)
            {
                string CLIENT_ID = rw["CLIENT_ID"].ToString();
                rw["CLIENT_ID"] = CLIENT_ID;

                string CLIENT_NAME = rw["CLIENT_NAME"].ToString();
                rw["CLIENT_NAME"] = CLIENT_NAME;
            }

            return(GetJson(dt));
        }
        public string GetProject_Type_Id()
        {
            RadDBImpl _dbImpl = new RadDBImpl();
            string    sql     = "select * from LKP_PROJECT_TYPE";
            DataTable dt      = _dbImpl.GetDataSet(sql).Tables[0];

            return(GetJson(dt));
        }
        public void deleteImage(string deviceId)
        {
            int       rowsAffected = 0;
            RadDBImpl _dbImpl      = new RadDBImpl();
            string    sql          = "delete from image where device_id = '" + deviceId + "'";

            try
            {
                rowsAffected = _dbImpl.ExeDML(sql);
            }
            catch { }
        }
        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 DataTable getUserInformation(string deviceId)
        {
            DataTable dt      = new DataTable();
            RadDBImpl _dbImpl = new RadDBImpl();

            try
            {
                string sql = "select device_name,phone_no,service_provider, userid,regkey from device a,device_users b where a.device_id = '" + deviceId + "' and a.device_id = b.device_id and active ='Y'";
                dt = _dbImpl.GetDataSet(sql).Tables[0];
            }
            catch {}

            return(dt);
        }
        public string GetSearchResult(string user_id, string fname, string lname, string bug_id)
        {
            RadDBImpl _dbImpl = new RadDBImpl();
            DataTable dt      = new DataTable();
            string    sql     = "select LC.NAME,C.CLIENT_NAME, P.BUG_ID,P.PROJECT_TYPE_ID,P.BUG_DESC,P.START_DT,P.END_DT,P.USER_ID,P.STATUS,P.ACTION_TAKEN,P.SESSION_ID,P.CONTACT_PERSON " +
                                " FROM PROJECT P,LKP_COMPANY LC,CLIENT C , LKP_USERS U " +
                                " WHERE P.USER_ID=U.USER_ID AND P.STATUS='Y' AND P.CLIENT_ID = C.CLIENT_ID AND P.COMPANY_ID = LC.COMPANY_ID";

            if (string.IsNullOrEmpty(user_id) && string.IsNullOrEmpty(fname) &&
                string.IsNullOrEmpty(lname) && string.IsNullOrEmpty(bug_id))
            {
                dt = _dbImpl.GetDataSet(sql).Tables[0];
            }
            else
            {
                if (!string.IsNullOrEmpty(user_id))
                {
                    sql = sql + " AND P.USER_ID='" + user_id.ToUpper() + "'";
                }

                if (!string.IsNullOrEmpty(fname))
                {
                    sql = sql + " AND U.FIRST_NAME='" + fname.ToUpper() + "'";
                }

                if (!string.IsNullOrEmpty(lname))
                {
                    sql = sql + " AND U.LAST_NAME='" + lname.ToUpper() + "'";
                }

                if (!string.IsNullOrEmpty(bug_id))
                {
                    sql = sql + " AND P.BUG_ID='" + bug_id.ToUpper() + "'";
                }

                sql = sql + " ORDER BY P.START_DT DESC";
                dt  = _dbImpl.GetDataSet(sql).Tables[0];
            }
            dt.Columns.Add("START", typeof(string));
            dt.Columns.Add("END", typeof(string));
            foreach (DataRow rw in dt.Rows)
            {
                string startdt = rw["START_DT"].ToString();
                rw["START"] = startdt;
                string enddt = rw["END_DT"].ToString();
                rw["END"] = enddt;
            }
            return(GetJson(dt));
        }
        public DataTable getUserLoginInfo(string userId)
        {
            DataTable dt      = new DataTable();
            RadDBImpl _dbImpl = new RadDBImpl();

            try
            {
                string sql = "select question,answer,password, userid from users where userid = '" + userId.ToUpper() + "'";
                dt = _dbImpl.GetDataSet(sql).Tables[0];
            }
            catch (Exception e)
            {
            }

            return(dt);
        }
        public string GetClient(string clientId)
        {
            string    sql     = string.Empty;
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(clientId))
            {
                sql = "select a.client_id,client_name,amt_charge,a.billing_Id,name ,b.company_id, bill_to from client a, CLIENT_COMPANY b ,lkp_company c , lkp_billing d where a.client_id = b.client_id and b.company_id = c.company_id and a.billing_id = d.billing_id ";
            }
            else
            {
                sql = "select a.client_id,client_name,amt_charge,a.billing_Id ,name,b.company_id, bill_to  from client a, CLIENT_COMPANY b ,lkp_company c , lkp_billing d where a.client_id = b.client_id  and b.company_id = c.company_id and a.billing_id = d.billing_id and client_id = '" + clientId.ToUpper() + "'";
            }

            DataTable dt = _dbImpl.GetDataSet(sql).Tables[0];

            //dt.Columns.Add("client_id", typeof(string));
            //dt.Columns.Add("client_name", typeof(string));
            //dt.Columns.Add("amt_charge", typeof(Double));
            //dt.Columns.Add("billing_id", typeof(string));

            foreach (DataRow rw in dt.Rows)
            {
                string client_id = rw["client_id"].ToString();
                rw["client_id"] = client_id;

                string client_name = rw["client_name"].ToString();
                rw["client_name"] = client_name;

                double amt_charge = Convert.ToDouble(rw["amt_charge"]);
                rw["amt_charge"] = amt_charge;

                string billing_Id = rw["billing_Id"].ToString();
                rw["billing_Id"] = billing_Id;

                string bill_to = rw["bill_to"].ToString();
                rw["bill_to"] = bill_to;

                string name = rw["name"].ToString();
                rw["name"] = name;

                string company_id = rw["company_id"].ToString();
                rw["company_id"] = company_id;
            }

            return(GetJson(dt));
        }
        public string GetBillingDetails(string billingId)
        {
            string    sql     = string.Empty;
            RadDBImpl _dbImpl = new RadDBImpl();

            if (string.IsNullOrEmpty(billingId))
            {
                sql = "select billing_id,bill_to,contact_person,address,city,state,country,zip from lkp_billing";
            }
            else
            {
                sql = "select billing_id,bill_to,contact_person,address,city,state,country,zip from lkp_billing where billing_id = '" + billingId.ToUpper() + "'";
            }

            DataTable dt = _dbImpl.GetDataSet(sql).Tables[0];


            foreach (DataRow rw in dt.Rows)
            {
                string billing_Id = rw["billing_id"].ToString();
                rw["billing_id"] = billing_Id;

                string bill_to = rw["bill_to"].ToString();
                rw["bill_to"] = bill_to;

                string contact_person = rw["contact_person"].ToString();
                rw["contact_person"] = contact_person;

                string BillAddress = rw["address"].ToString();
                rw["address"] = BillAddress;

                string Bill_city = rw["city"].ToString();
                rw["city"] = Bill_city;

                string Bill_state = rw["state"].ToString();
                rw["state"] = Bill_state;

                string Bill_country = rw["country"].ToString();
                rw["country"] = Bill_country;

                string bill_zip = rw["zip"].ToString();
                rw["zip"] = bill_zip;
            }

            return(GetJson(dt));
        }
        public DataTable GetReportDS()
        {
            string    sql     = string.Empty;
            RadDBImpl _dbImpl = new RadDBImpl();

            sql = "SELECT BILL.BILLING_ID, BILL.BILL_TO, BILL.CONTACT_PERSON, BILL.ADDRESS, "
                  + " BILL.CITY, BILL.STATE, BILL.COUNTRY, BILL.ZIP,CL.CLIENT_NAME, "
                  + " CL.AMT_CHARGE,CL.CLIENT_ID,P.BUG_ID, P.BUG_DESC, P.START_DT, P.END_DT "
                  + " FROM LKP_BILLING BILL, CLIENT CL, PROJECT P "
                  + " WHERE  BILL.BILLING_ID = CL.BILLING_ID AND CL.CLIENT_ID = P.CLIENT_ID";

            DataTable dt = _dbImpl.GetDataSet(sql).Tables[0];



            return(dt);
        }
        public string GetProjectDetail(string bug_id)
        {
            RadDBImpl _dbImpl = new RadDBImpl();
            string    sql     = "select A.* , C.NAME, D.CLIENT_NAME from project A , CLIENT_COMPANY B , LKP_COMPANY C , CLIENT D where A.CLIENT_ID = B.CLIENT_ID AND A.COMPANY_ID = B.COMPANY_ID AND B.COMPANY_ID= C.COMPANY_ID AND B.CLIENT_ID = D.CLIENT_ID AND A.CLIENT_ID= D.CLIENT_ID AND  bug_id='" + bug_id.ToUpper() + "'";
            DataTable dt      = _dbImpl.GetDataSet(sql).Tables[0];

            dt.Columns.Add("START", typeof(string));
            dt.Columns.Add("END", typeof(string));
            foreach (DataRow rw in dt.Rows)
            {
                string startdt = rw["START_DT"].ToString();
                rw["START"] = startdt;
                string enddt = rw["END_DT"].ToString();
                rw["END"] = enddt;
            }
            return(GetJson(dt));
        }
        public bool CheckUser(string UserId, string password)
        {
            RadDBImpl _dbImpl = new RadDBImpl();
            DataTable dt      = new DataTable();

            dt.Columns.Add("check", typeof(string));
            DataRow dr  = dt.NewRow();
            bool    val = false;
            string  sql = "select USER_ID from LKP_USERS where USER_ID = '" + UserId.ToUpper() + "' and PASSWORD = '******'";

            if (string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(password))
            {
                //dr["check"] = "false";
                //dt.Rows.Add(dr);
                return(val);
            }
            using (IDataReader reader = _dbImpl.GetDataReader(sql))
            {
                try
                {
                    if (reader.Read())
                    {
                        //dr["check"] = "true";
                        //dt.Rows.Add(dr);
                        val = true;
                    }
                    else
                    {
                        //dr["check"] = "false";
                        //dt.Rows.Add(dr);
                        val = false;
                    }
                }
                catch
                { }
                finally
                {
                    reader.Close();
                }
            }
            //Logging.WriteMessage("Check User" + UserId.ToUpper() + " - " + val);

            //return GetJson(dt);
            return(val);
        }