public async Task <Data.costomar> CreateCostomer(Data.costomar costomar) { _sqLiteConnection = await DependencyService.Get <ISQLite>().GetConnection(); //var db = new ISQLite().Connition; int res = _sqLiteConnection.Insert(costomar); if (res > 0) { var costomar_res = await getcostomar_id(costomar); if (costomar_res != null) { return(costomar_res); } else { return(null); } } else { return(null); } var x = 0; }
public async Task <Data.costomar> getcostomar_id(Data.costomar costomar) { _sqLiteConnection = await DependencyService.Get <ISQLite>().GetConnection(); var existingcostomar = _sqLiteConnection.Query <Data.costomar>("select * from costomar where name = ? and phone1 = ? and IDnum = ? and address = ?", costomar.name, costomar.phone1, costomar.IDnum, costomar.address).FirstOrDefault(); if (existingcostomar != null) { return(existingcostomar); } else { var res = 0; return(null); } }
public async Task <int> UpdateCostomer(Data.costomar costomar) { _sqLiteConnection = await DependencyService.Get <ISQLite>().GetConnection(); var existingcostomar = _sqLiteConnection.Query <Data.costomar>("select * from costomar where costomar_id = ?", costomar.costomar_id).FirstOrDefault(); if (existingcostomar != null) { var res = _sqLiteConnection.Update(costomar); return(res); } else { var res = 0; return(res); } #region ubdate Comment ------------------------ //var db = new ISQLite().Connition; //var res =_sqLiteConnection.Execute( // "UPDATE costomar " + // "SET name = " + costomar.name + // ",phone1 = " + costomar.phone1 + // ",phone2 = " + costomar.phone2 + // ",phone3 = " + costomar.phone3 + // ",IDnum = " + costomar.IDnum + // ",address = " + costomar.address + // ",BuildingNUM = " + costomar.BuildingNUM + // ",flatNum = " + costomar.flatNum + // ",Email = " + costomar.Email + // ",guarantorName = " + costomar.guarantorName + // ",guarantorphone = " + costomar.guarantorphone + // ",ban = " + costomar.ban + // ",costomarColor = " + costomar.costomarColor + // ",voucherNUM = " + costomar.voucherNUM + // " WHERE employeeid = ? ;" , costomar.costomar_id); //var res = _sqLiteConnection.Query<Data.costomar>( // "UPDATE costomar " + // "SET name = " + costomar.name + // ",phone1 = " + costomar.phone1 + // ",phone2 = " + costomar.phone2 + // ",phone3 = " + costomar.phone3 + // ",IDnum = " + costomar.IDnum + // ",address = " + costomar.address + // ",BuildingNUM = " + costomar.BuildingNUM + // ",flatNum = " + costomar.flatNum + // ",Email = " + costomar.Email + // ",guarantorName = " + costomar.guarantorName + // ",guarantorphone = " + costomar.guarantorphone + // ",ban = " + costomar.ban + // ",costomarColor = " + costomar.costomarColor + // ",voucherNUM = " + costomar.voucherNUM + // " WHERE employeeid = "+ costomar.costomar_id +";"); //var existingcostomar = _sqLiteConnection.Query<Data.costomar>("select * from costomar where costomar_id = ?", costomar.costomar_id).FirstOrDefault(); //if (existingcostomar != null) //{ // existingcostomar.name = costomar.name; // _sqLiteConnection.RunInTransaction(() => // { // _sqLiteConnection.Update(existingcostomar); // }); // var res = 1; // return res; //} //else //{ // var res = 0; // return res; //} #endregion }