Ejemplo n.º 1
0
        public static company getComapnyData(int id)
        {
            DataBase  db  = new DataBase();
            DataTable dt  = new DataTable();
            string    sql = "select * from CompanysTable where CompanyId = " + id;

            dt = db.ExecuteReader(sql);
            company company = new company();

            company.CompanyId   = id;
            company.CompanyName = dt.Rows[0]["CompanyName"].ToString();
            company.logo        = dt.Rows[0]["logo"].ToString();
            company.contact     = dt.Rows[0]["contact"].ToString();
            company.siteAddress = dt.Rows[0]["siteAddress"].ToString();
            company.apiAddress  = dt.Rows[0]["apiAddress"].ToString();
            company.remarks     = dt.Rows[0]["remarks"].ToString();
            return(company);
        }
Ejemplo n.º 2
0
        public static int saveCompany(company company)
        {
            DataBase db = new DataBase();
            string   sql;

            if (company.CompanyId == 0)
            {
                sql = "insert into CompanysTable (CompanyName,Logo,Contact,SiteAddress,ApiAddress,Remarks) values ('" + company.CompanyName + "','" + company.logo + "','" + company.contact + "','" + company.siteAddress + "','" + company.apiAddress + "','" + company.remarks + "')";
            }
            else
            {
                sql = "update CompanysTable set CompanyName = '" + company.CompanyName + "',Logo = '" + company.logo + "',Contact = '" + company.contact + "',SiteAddress = '" + company.siteAddress + "',ApiAddress = '" + company.apiAddress + "',Remarks = '" + company.remarks + "' where CompanyId = " + company.CompanyId;
            }
            int successFlag = db.ExecuteNonQuery(sql);

            if (successFlag > 0)
            {
                return(db.GetMaxId("CompanysTable", "CompanyId"));
            }
            return(-1);
        }