text
stringlengths
10
2.72M
package com.tt.miniapp.msg.audio.bg; import android.text.TextUtils; import com.tt.frontendapiinterface.a; import com.tt.frontendapiinterface.b; import com.tt.miniapp.audio.background.BgAudioManagerClient; import com.tt.miniapphost.AppBrandLogger; import com.tt.option.e.e; import org.json.JSONObject; public class ApiOperateBgAudioCtrl extends b { public ApiOperateBgAudioCtrl(String paramString, int paramInt, e parame) { super(paramString, paramInt, parame); } public void act() { try { JSONObject jSONObject = new JSONObject(this.mArgs); String str = jSONObject.optString("operationType"); BgAudioManagerClient.TaskListener taskListener = new BgAudioManagerClient.TaskListener() { public void onFail(String param1String, Throwable param1Throwable) { ApiOperateBgAudioCtrl.this.callbackFail(param1String, param1Throwable); } public void onSuccess() { ApiOperateBgAudioCtrl.this.callbackOk(); } }; if (TextUtils.equals(str, "play")) { BgAudioManagerClient.getInst().play(taskListener); return; } if (TextUtils.equals(str, "pause")) { BgAudioManagerClient.getInst().pause(taskListener); return; } if (TextUtils.equals(str, "stop")) { BgAudioManagerClient.getInst().stop(taskListener); return; } if (TextUtils.equals(str, "seek")) { int i = jSONObject.optInt("currentTime"); BgAudioManagerClient.getInst().seek(i, taskListener); return; } callbackFail(a.b("operationType")); return; } catch (Exception exception) { AppBrandLogger.eWithThrowable("tma_ApiOperateBgAudioCtrl", "act", exception); callbackFail(exception); return; } } public String getActionName() { return "operateBgAudio"; } } /* Location: C:\Users\august\Desktop\tik\df_miniapp\classes.jar!\com\tt\miniapp\msg\audio\bg\ApiOperateBgAudioCtrl.class * Java compiler version: 6 (50.0) * JD-Core Version: 1.1.3 */
public class Body { public double xxPos; public double yyPos; public double xxVel; public double yyVel; public double mass; public String imgFileName = "jupiter.gif"; public static double G = 6.67e-11; public Body(double xP, double yP, double xV, double yV, double m, String fname) { xxPos = xP; yyPos = yP; xxVel = xV; yyVel = yV; mass = m; imgFileName = fname; } public Body(Body b) { xxPos = b.xxPos; yyPos = b.yyPos; xxVel = b.xxVel; yyVel = b.yyVel; mass = b.mass; imgFileName = b.imgFileName; } public double calcDistance(Body b) { return Math.sqrt((xxPos-b.xxPos)*(xxPos-b.xxPos)+(yyPos-b.yyPos)*(yyPos-b.yyPos)); } public boolean equals(Body b) { if (xxPos == b.xxPos && yyPos == b.yyPos && xxVel == b.xxVel && yyVel == b.yyVel && mass == b.mass && imgFileName == b.imgFileName) { return true; } else { return false; } } public double calcForceExertedBy(Body b) { if (this.equals(b)) {return 0.0;} double dist = this.calcDistance(b); return (G * mass * b.mass) / dist / dist; } public double calcForceExertedByX(Body b) { if (this.equals(b)) {return 0.0;} double dist = this.calcDistance(b); return (b.xxPos-xxPos) * G * mass * b.mass / Math.pow(dist,3); } public double calcForceExertedByY(Body b) { if (this.equals(b)) {return 0.0;} double dist = this.calcDistance(b); return (b.yyPos-yyPos) * G * mass * b.mass / Math.pow(dist,3); } public double calcNetForceExertedByX(Body[] bodys) { double force = 0.0; for (int i = 0; i < bodys.length; i++) { force += this.calcForceExertedByX(bodys[i]); } return force; } public double calcNetForceExertedByY(Body[] bodys) { double force = 0.0; for (int i = 0; i < bodys.length; i++) { force += this.calcForceExertedByY(bodys[i]); } return force; } public void update(double dt, double fx, double fy) { xxVel += dt * fx / mass; yyVel += dt * fy / mass; xxPos += dt * xxVel; yyPos += dt * yyVel; return; } public void draw() { StdDraw.picture(xxPos, yyPos, "./images/"+imgFileName); return; } }
package prj5; import java.io.FileNotFoundException; import java.util.Arrays; import student.TestCase; /** * @author <Natalie Kakish> <nataliekakish> * @version 11/9/2019 * * This tests the SurveyReader class to ensure it's reading correctly * */ public class SurveyReaderTest extends TestCase { private SurveyReader sReader; /** * sets up the test class */ public void setUp() throws FileNotFoundException { sReader = new SurveyReader("SongList2019FTest.csv", "MusicSurveyData2019F.csv"); } /** * tests the readSongFile method */ public void testReadSongsFile() { LinkedList<Song> songs = sReader.getSongs(); assertEquals(6, songs.getSize()); assertEquals("Another One Bites the Dust", songs.get(2).getSong()); assertEquals("Queen", songs.get(2).getArtist()); assertEquals("1980", songs.get(2).getYear()); assertEquals("disco", songs.get(2).getGenre()); } /** * tests the readSurveyData method */ public void testReadSurveyDataFile() { LinkedList<Student> students = sReader.getStudents(); int[] songPref = new int[] { -1, -1, -1, -1, 1, 1, 1, -1, 0, 0 }; assertEquals(267, students.getSize()); assertEquals("Math or CMDA", students.get(1).getMajor()); assertEquals("Northeast", students.get(1).getRegion()); assertEquals("music", students.get(1).getHobby()); Arrays.equals(students.get(1).getSongPref(), songPref); } }
package edu.stanford.iftenney; /** * Created by iftenney on 11/12/14. */ public class IOTools { }
public class absclassmethodext extends absclassmethod { public void disp2() { System.out.println("overriding abstract method"); } public static void main(String args[]){ absclassmethodext obj = new absclassmethodext(); obj.disp2(); } }
//This is ws.ICalculator.java file. package ws; import java.util.Vector; public interface ICalculator { public Vector<Integer> getPrimeList(int lower, int upper); public Vector<String> sortString(Vector<String> list, String order); }
package exer1; public class Cat extends Animal { public int num = 20; public Cat(String name,int age) { super(name,age); } public void catchMouse(){ System.out.println("猫抓老鼠"); } public void eat(){ System.out.println("猫吃鱼"); } public void method(){ int num = 30; System.out.println("num = " + num); System.out.println("this.num = " + this.num); System.out.println("super.num = " + super.num); } }
package com.groupdocs.ui.signature.signer; import com.groupdocs.signature.options.imagesignature.*; import com.groupdocs.ui.signature.model.web.SignatureDataEntity; /** * ImageSigner * Signs documents with the image signature * * @author Aspose Pty Ltd */ public class ImageSigner extends Signer { /** * Constructor * * @param signatureData */ public ImageSigner(SignatureDataEntity signatureData) { super(signatureData); } /** * Add image signature data to pdf sign options * * @return PdfSignImageOptions */ @Override public PdfSignImageOptions signPdf() { // setup options // setup image signature options PdfSignImageOptions signOptions = new PdfSignImageOptions(signatureData.getSignatureGuid()); fillImageOptions(signOptions); return signOptions; } private void fillImageOptions(SignImageOptions signOptions) { signOptions.setLeft(signatureData.getLeft()); signOptions.setTop(signatureData.getTop()); signOptions.setWidth(signatureData.getImageWidth()); signOptions.setHeight(signatureData.getImageHeight()); signOptions.setDocumentPageNumber(signatureData.getPageNumber()); signOptions.setRotationAngle(signatureData.getAngle()); } /** * Add image signature data to image sign options * * @return ImageSignImageOptions */ @Override public ImagesSignImageOptions signImage() { // setup image signature options with relative path - image file stores in config.ImagesPath folder ImagesSignImageOptions signOptions = new ImagesSignImageOptions(signatureData.getSignatureGuid()); fillImageOptions(signOptions); return signOptions; } /** * Add image signature data to words sign options * * @return WordsSignImageOptions */ @Override public WordsSignImageOptions signWord() { // setup image signature options with relative path - image file stores in config.ImagesPath folder WordsSignImageOptions signOptions = new WordsSignImageOptions(signatureData.getSignatureGuid()); fillImageOptions(signOptions); return signOptions; } /** * Add image signature data to cells sign options * * @return CellsSignImageOptions */ @Override public CellsSignImageOptions signCells() { // setup image signature options CellsSignImageOptions signOptions = new CellsSignImageOptions(signatureData.getSignatureGuid()); fillImageOptions(signOptions); return signOptions; } /** * Add image signature data to slides sign options * * @return SlidesSignImageOptions */ @Override public SlidesSignImageOptions signSlides() { // setup image signature options with relative path - image file stores in config.ImagesPath folder SlidesSignImageOptions signOptions = new SlidesSignImageOptions(signatureData.getSignatureGuid()); fillImageOptions(signOptions); return signOptions; } }
package com.wb.cloud.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; /** * @ClassName : OrderNacosController * @Author : 王斌 * @Date : 2020-11-30 14:12 * @Description * @Version */ @RestController public class OrderNacosController { @Autowired private RestTemplate restTemplate; @Value("${service-url.nacos-user-service}") private String SERVICE_PATH; @GetMapping("/consumer/payment/nacos/{id}") public String getPayment(@PathVariable("id") long id){ return restTemplate.getForObject(SERVICE_PATH + "/payment/nacos/" + id,String.class); } }
package com.tencent.mm.plugin.collect.b; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import com.tencent.mm.platformtools.w; import com.tencent.mm.platformtools.w.a; import com.tencent.mm.platformtools.w.b; import com.tencent.mm.sdk.platformtools.x; public final class c implements w { private b hTJ = new 1(this); private String url; public c(String str) { this.url = str; } public final String Vv() { return com.tencent.mm.plugin.wallet_core.d.b.JC(this.url); } public final String Vw() { return this.url; } public final String Vx() { return this.url; } public final String getCacheKey() { return this.url; } public final boolean Vy() { return true; } public final boolean Vz() { return false; } public final Bitmap VA() { return null; } public final Bitmap a(Bitmap bitmap, a aVar, String str) { if (a.evZ == aVar) { try { com.tencent.mm.sdk.platformtools.c.a(bitmap, 100, CompressFormat.PNG, com.tencent.mm.plugin.wallet_core.d.b.JC(this.url), false); } catch (Throwable e) { x.printErrStackTrace("MicroMsg.WalletGetPicStrategy", e, "", new Object[0]); } } return bitmap; } public final void VB() { } public final void P(String str, boolean z) { } public final void a(a aVar, String str) { } public final b Vu() { return this.hTJ; } }
package com.decrypt.beeglejobsearch.mvp.views; import com.decrypt.beeglejobsearch.data.storage.ProductDto; public interface IProductView extends IView { public void showProductView(ProductDto product); public void updateProductCountView(ProductDto product); }
/** * Async helpers. */ package com.faizalsidek.inventory.async;
package lesson15.task1; import lesson11.task1.Printable; public class User3 { public static void main(String[] args) { Printable printable = new Printable() { @Override public void print() { System.out.println("печать ананимного класса"); } }; printable.print(); } }
package com.huawei.esdk.tp.professional.local.bean; import java.util.Map; public class SiteDeviceVersionInfoEx { protected String model; protected String license; protected String softVersion; protected String hardVersion; protected String logicVersion; protected Map<String,String> micVersion; protected String manufacturer; /** * Gets the value of the model property. * * @return * possible object is * {@link String } * */ public String getModel() { return model; } /** * Sets the value of the model property. * * @param value * allowed object is * {@link String } * */ public void setModel(String value) { this.model = value; } /** * Gets the value of the lisence property. * * @return * possible object is * {@link String } * */ public String getLicense() { return license; } /** * Sets the value of the lisence property. * * @param value * allowed object is * {@link String } * */ public void setLicense(String value) { this.license = value; } /** * Gets the value of the softVersion property. * * @return * possible object is * {@link String } * */ public String getSoftVersion() { return softVersion; } /** * Sets the value of the softVersion property. * * @param value * allowed object is * {@link String } * */ public void setSoftVersion(String value) { this.softVersion = value; } /** * Gets the value of the hardVersion property. * * @return * possible object is * {@link String } * */ public String getHardVersion() { return hardVersion; } /** * Sets the value of the hardVersion property. * * @param value * allowed object is * {@link String } * */ public void setHardVersion(String value) { this.hardVersion = value; } /** * Gets the value of the logicVersion property. * * @return * possible object is * {@link String } * */ public String getLogicVersion() { return logicVersion; } /** * Sets the value of the logicVersion property. * * @param value * allowed object is * {@link String } * */ public void setLogicVersion(String value) { this.logicVersion = value; } /** * Gets the value of the micVersion property. * * <p> * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a <CODE>set</CODE> method for the micVersion property. * * <p> * For example, to add a new item, do as follows: * <pre> * getMicVersion().add(newItem); * </pre> * * * <p> * Objects of the following type(s) are allowed in the list * {@link VersionMap } * * */ public Map<String,String> getMicVersion() { return this.micVersion; } /** * Gets the value of the manufacturer property. * * @return * possible object is * {@link String } * */ public String getManufacturer() { return manufacturer; } /** * Sets the value of the manufacturer property. * * @param value * allowed object is * {@link String } * */ public void setManufacturer(String value) { this.manufacturer = value; } /** * Sets the value of the micVersion property. * * @param value * allowed object is * {@link VersionMap } * */ public void setMicVersion(Map<String,String> micVersion) { this.micVersion = micVersion; } }
package simple.mvc.repository; import java.util.List; import simple.mvc.jpa.Product; public interface ProductRepository { List<Product> getAllProducts(); }
/** * */ package hackerRank; import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; /** * @author Tina * */ public class oddEven { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner in = new Scanner(System.in); int t = in.nextInt(); String even = ""; String odd = ""; String[] ar = new String[t]; for(int i = 0; i < t; i++){ ar[i] = in.next(); } for(int j = 0; j < t; j++){ for(int k = 0; k < ar[j].length(); k++){ char c = ar[j].charAt(k); if(k%2 == 0){ even = even.concat(Character.toString(c)); }else { odd= odd.concat(Character.toString(c)); } } System.out.println(even +" "+ odd); even = ""; odd = ""; } } }
package com.tencent.mm.plugin.fav.ui; import com.tencent.mm.plugin.fav.ui.widget.FavSearchActionView; class FavSearchUI$4 implements Runnable { final /* synthetic */ FavSearchUI iZQ; FavSearchUI$4(FavSearchUI favSearchUI) { this.iZQ = favSearchUI; } public final void run() { FavSearchActionView a = FavSearchUI.a(this.iZQ); if (a.jat != null) { a.jat.crO(); } this.iZQ.showVKB(); } }
import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; public class LocalDateTimeDemo { public static void main(String[] args) { LocalDateTime localDateTime1 = LocalDateTime.parse("2018-02-03T12:30:30"); System.out.println("localDateTime1 = "+localDateTime1); /* * Parameters: * * amountToAdd - the amount of the unit to add to the result, * may be negative * * unit - the unit of the amount to add, not null * * Returns:a LocalDateTime based on this date-time with the * specified amount added, not null */ LocalDateTime localDateTime2 = localDateTime1.plus(5, ChronoUnit.MONTHS); System.out.println("Month Added = "+localDateTime2); /* * Parameters: * * amountToSubtract - the amount of the unit to subtract from * the result, may be negative * * unit - the unit of the amount to subtract, not null * * Returns:a LocalDateTime based on this date-time with the * specified amount subtracted, not null */ LocalDateTime localDateTime3 = localDateTime1.minus(5,ChronoUnit.YEARS); System.out.println("Years reduced = "+localDateTime3); } }
import java.nio.ByteBuffer; import java.nio.ByteOrder; public class MessageCS { private int opcode; private int count; private int offset; private String name; private final int BUF_SIZE = 1000; public MessageCS(int opcoud, int caunt, int ofset, String neim){ this.opcode = opcoud; this.count = caunt; this.offset = ofset; this.name = neim; } /* public byte[] getByteRepr() { ByteBuffer bb = ByteBuffer.allocate(4 * Integer.BYTES + BUF_SIZE); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putInt(this.opcode); bb.putInt(this.count); bb.putInt(this.offset); bb.put(name); return bb.array(); }*/ public byte[] getByteRepr() { ByteBuffer bb = ByteBuffer.allocate(4 * Integer.BYTES + 255); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putInt(this.opcode); bb.putInt(this.count); bb.putInt(this.offset); for (int i = 0; i < this.name.length(); i++) bb.put((byte) this.name.charAt(i)); return bb.array(); } public int getOpcode() { return opcode; } public int getCount() { return count; } public int getOffset() { return offset; } public String getName() { return name; } public void setOpcode(int opcoud) { opcode = opcoud; } public void setCount(int caunt) { count = caunt; } public void setOffset(int ofset) { offset = ofset; } public void setName(String neim) { name = neim; } }
package com.phone4s.www.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.phone4s.www.model.RepairBussiness; import com.phone4s.www.service.RepairBussinessService; @Controller public class RepairBussinessController { @Autowired private RepairBussinessService repairBussinessService; @RequestMapping("/getTopRepairBussiness") public @ResponseBody List<RepairBussiness> getGoodsPhone(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) { model.addAttribute("name", name); List<RepairBussiness> topRepairBussiness = this.repairBussinessService.getTopRepairBussiness(); model.addAttribute("topRepairBussiness", topRepairBussiness); return topRepairBussiness; } }
package com.example.demo.domain; import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; //护工 public class Nursing { private int id; //名字 private String n_name; private String sex; private Integer age; //籍贯 private String native_place; //住址 private String address; //更新时间 @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8") private Date update_time; //工作经验 private String work_experience; //最低薪资 private Integer low_salary; //最高薪资 private Integer top_salary; //属相 private String shuxiang; //名族 private String nation; //身高 private float height; //体重 private float weight; //语言 private String language; //照片url private String picture; //固话 private String tel; //手机 private String phone; //简介 private String intro; private String main_tasks; public Date getUpdate_time() { return update_time; } public void setUpdate_time(Date update_time) { this.update_time = update_time; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getN_name() { return n_name; } public void setN_name(String n_name) { this.n_name = n_name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getNative_place() { return native_place; } public void setNative_place(String native_place) { this.native_place = native_place; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getWork_experience() { return work_experience; } public void setWork_experience(String work_experience) { this.work_experience = work_experience; } public Integer getLow_salary() { return low_salary; } public void setLow_salary(Integer low_salary) { this.low_salary = low_salary; } public Integer getTop_salary() { return top_salary; } public void setTop_salary(Integer top_salary) { this.top_salary = top_salary; } public String getShuxiang() { return shuxiang; } public void setShuxiang(String shuxiang) { this.shuxiang = shuxiang; } public String getNation() { return nation; } public void setNation(String nation) { this.nation = nation; } public float getHeight() { return height; } public void setHeight(float height) { this.height = height; } public float getWeight() { return weight; } public void setWeight(float weight) { this.weight = weight; } public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } public String getMain_tasks() { return main_tasks; } public void setMain_tasks(String main_tasks) { this.main_tasks = main_tasks; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public String getTel() { return tel; } public void setTel(String tel) { this.tel = tel; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getIntro() { return intro; } public void setIntro(String intro) { this.intro = intro; } }
package test; import java.io.IOException; import org.xml.sax.*; import uk.co.wilson.xml.MinML; //import uk.co.wilson.xml.SysBuild; import java.io.BufferedInputStream; import java.io.InputStreamReader; public class MinMLTest extends MinML { public MinMLTest() { // new SysBuild(); ///* try { parse(new InputStreamReader(new BufferedInputStream(new java.io.FileInputStream("C:/Documents and Settings/lelguea/Mis documentos/Downloads/mapserv_orto.xml"), 1024))); // parse(new InputStreamReader(new BufferedInputStream(System.in, 1024))); } catch (final IOException e) { System.out.println("IOException: " + e); e.printStackTrace(); } catch (final SAXException e) { System.out.println("SAXException: " + e); e.printStackTrace(); } catch (final Throwable e) { System.out.println("Other Exception: " + e); e.printStackTrace(); } //*/ } @Override public void startDocument() { System.out.println("Start of Document"); } @Override public void endDocument() { System.out.println("End of Document"); } @Override public void startElement (String name, AttributeList attributes) { System.out.println("Start of Element: \"" + name + "\""); System.out.println("Start of Attributes"); for (int i = 0; i < attributes.getLength(); i++) System.out.println("Name: \"" + attributes.getName(i) + "\" Type: " + attributes.getType(i) + " Value: \"" + attributes.getValue(i) + "\""); System.out.println("End of Attributes"); } @Override public void endElement (String name) { System.out.println("End of Element: \"" + name + "\""); } @Override public void characters (char ch[], int start, int length) { System.out.println("Characters: \"" + new String(ch, start, length) + "\""); } @Override public void fatalError (SAXParseException e) throws SAXException { System.out.println("Error: " + e); throw e; } public static void main (final String[] args) { new MinMLTest(); } }
public class Course { private String courseName; private String instructor; private int numCredits; private int currentEnrollment; private int maxStudents; private Student[] enrollment; public Course(String courseName, String instructor, int numCredits, int maxStudents) { this.courseName = courseName; this.instructor = instructor; this.numCredits = numCredits; this.maxStudents = maxStudents; this.currentEnrollment = 0; this.enrollment = new Student[maxStudents]; } public String getCourseName() { return courseName; } public String getInstructor() { return instructor; } public int getNumCredits() { return numCredits; } public Student[] getEnrollment() { return enrollment; } public int spacesAvailable() { return (this.maxStudents - this.currentEnrollment); } public void enroll(Student s) { if ( spacesAvailable() >= 1) { enrollment[currentEnrollment] = s; currentEnrollment++; } } }
package com.ntil.habiture; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.habiture.PokeData; import java.util.ArrayList; import java.util.List; /** * Created by Reid on 2015/6/22. */ public class FounderAdapter extends PagerAdapter{ private static final boolean DEBUG = false; private List<Item> items; private Bitmap bmpTool; private Context context; private Listener listener; private ImageView ivPoke; private Bitmap bmpDrawing; private int vpWidth = -1, vpHeight = -1; private boolean isFirstPhotoSeted = false; private int nFounderSize = 0; private void trace(String message) { if(DEBUG) Log.d("FounderAdapter", message); } LayoutInflater mInflater; public class Item { PokeData.Founder founder; Bitmap photo = null; ImageView ivPoke = null; public PokeData.Founder getFounder() { return founder; } } public FounderAdapter(Context context, List<PokeData.Founder> founderList) { this.context = context; listener = (Listener) context; mInflater = LayoutInflater.from(context); items = new ArrayList<>(founderList.size()); for(PokeData.Founder founder: founderList) { Item item = new Item(); item.founder = founder; items.add(item); } } @Override public int getCount() { return items.size(); } @Override public boolean isViewFromObject(View view, Object o) { return view == o; } @Override public void destroyItem(ViewGroup container, int position, Object object) { // Just remove the view from the ViewPager container.removeView((View) object); } @Override public int getItemPosition(Object object) { return POSITION_NONE; } @Override public Object instantiateItem(ViewGroup container, int position) { // Get the item for the requested position final Item item = items.get(position); trace("instantiateItem position = " + position); // Inflate item layout for images ImageView ivOwnerPhoto = (ImageView) mInflater .inflate(R.layout.singleitem_owner_image, container, false); item.ivPoke = ivOwnerPhoto; if(item.photo != null) { ivOwnerPhoto.setImageBitmap(item.photo); if(!isFirstPhotoSeted && position == 0) { nFounderSize++; trace("nFounderSize = "+nFounderSize); if(nFounderSize == items.size()) { trace("item.photo != null"); setPokeEnabled(0); isFirstPhotoSeted = true; nFounderSize = 0; } } } container.addView(ivOwnerPhoto); return ivOwnerPhoto; } public void setPhoto(byte[] photo, int position) { trace("setPhoto position = "+position+", vpWidth, vpHeight = "+vpWidth +", "+vpHeight); Item item = (Item) items.get(position); item.photo = BitmapFactory.decodeByteArray(photo, 0, photo.length); if(vpWidth <= 0 || vpHeight <= 0) { //item.photo = BitmapFactory.decodeByteArray(photo, 0, photo.length); } else { item.photo = Bitmap.createScaledBitmap(item.photo, vpWidth, vpHeight, false); } notifyDataSetChanged(); } private void drawSampleTool(float x, float y) { Paint paint = new Paint(); Canvas drawCanvas = new Canvas(bmpDrawing); drawCanvas.drawBitmap(bmpTool, x, y, paint); ivPoke.setImageBitmap(bmpDrawing); } public void setPokeEnabled(final int position) { trace("setPokeEnabled"); Item item = (Item) items.get(position); if(bmpTool != null) {bmpTool.recycle();} bmpTool = BitmapFactory.decodeResource(context.getResources(), R.drawable.sample_tool).copy(Bitmap.Config.ARGB_8888, true); ivPoke = item.ivPoke; if(bmpDrawing!=null) bmpDrawing.recycle(); bmpDrawing = item.photo.copy(Bitmap.Config.ARGB_8888, true); ivPoke.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //trace("onTouch event = "+ event.getAction()); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: return true; case MotionEvent.ACTION_MOVE: return true; case MotionEvent.ACTION_UP: trace("ACTION_UP"); listener.onPoke(position); drawSampleTool(event.getX(), event.getY()); } return false; } }); } public void setViewPagerShape(int width, int height) { vpWidth = width; vpHeight = height; trace("setViewPagerShape vpWidth, vpHeight = "+vpWidth +", "+vpHeight); } public void release() { for(Item item: items) if(item.photo != null) item.photo.recycle(); if(bmpDrawing != null) bmpDrawing.recycle(); if(bmpTool != null) bmpTool.recycle(); } public interface Listener { void onPoke(int position); } }
package serverPart; import game.Game; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import constants.Constants; public class SessionsHandler { private Collection<Gamer> sessions = new ArrayList<Gamer>(); private Collection<Game> games = new ArrayList<Game>(); public synchronized ArrayList<String> addGamer(Gamer g) { this.sessions.add(g); if(games.isEmpty()) { Game game = new Game(); this.games.add(game); } Game playersGame = null; for(Game gz : games) { if(gz.getPlayersCount() < Constants.CardsPerPlayer) { gz.addGamer(g); playersGame = gz; break; } } if(playersGame == null) { playersGame = new Game(); this.games.add(playersGame); playersGame.addGamer(g); } return this.otherGamersNames(g, playersGame); } public synchronized ArrayList<String> checkOtherGamers(Gamer g) { Game playersGame = null; for(Game gm : this.games) { if(gm.containsGamer(g)) { playersGame = gm; break; } } if(playersGame != null) { return this.otherGamersNames(g, playersGame); } else { return new ArrayList<String>(); } } private ArrayList<String> otherGamersNames(Gamer thisGamer, Game g) { return g.getGamers(thisGamer); } public Iterator<Gamer> iterator(){ return sessions.iterator(); } public synchronized void removePlayer(Gamer g) { this.sessions.remove(g); for(Game gm : this.games) { if(gm.removeGamer(g) == true) { break; } } } public synchronized boolean gamerStartsGame(Gamer g) { for(Game game : this.games) { if(game.containsGamer(g)) { return game.gamerStartedGame(g); } } return false; } }
package Trabalho3; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.Dimension; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EtchedBorder; public class TilePanel extends JPanel { private static final long serialVersionUID = 1L; private JLabel imageComponent; private JPanel playersPanel; private ImageIcon[] imagesIcon; private ImageIcon[] pinsIcon; public TilePanel( int id, int numberOfPlayers, ViewerParameters param ) { super( new BorderLayout() ); imagesIcon = param.getTilesIcons(); pinsIcon = param.getSmallPinsIcons(); setBorder( new EtchedBorder( EtchedBorder.LOWERED ) ); JPanel numberComponent = new JPanel( new FlowLayout( FlowLayout.LEFT ) ); numberComponent.add( new JLabel( id + "" ) ); add( numberComponent, BorderLayout.EAST ); imageComponent = newLabel( param.getTileDim() ); add( imageComponent, BorderLayout.CENTER ); playersPanel = new JPanel( new GridLayout( 1, 0) ); for ( int i= 0; i < numberOfPlayers; ++i) playersPanel.add( newLabel( param.getSmallPinDim() ) ); add( playersPanel, BorderLayout.SOUTH ); } public void playerExited( int playerId ) { getPinComponent( playerId ).setIcon( null ); } public void playerEntered( int playerId ) { getPinComponent(playerId).setIcon( pinsIcon[ playerId ] ); } public void changeImageTo( String description ) { imageComponent.setIcon( IconsUtils.getIcon( this.imagesIcon, description ) ); } private JLabel getPinComponent( int playerId ) { return (JLabel)playersPanel.getComponent( playerId ); } private static JLabel newLabel( Dimension dim ) { JLabel l = new JLabel(); l.setPreferredSize( dim ); return l; } }
package kg.inai.equeuesystem.entities; import lombok.*; import lombok.experimental.FieldDefaults; import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.*; import java.util.Date; @Getter @Setter @Builder @NoArgsConstructor @AllArgsConstructor @FieldDefaults(level = AccessLevel.PRIVATE) @Table(name = "payment") @Entity public class Payment { @Id @GeneratedValue @Column(name = "payment_id") Long id; @Column(name = "payment_amount", nullable = false) Double amount; @DateTimeFormat(pattern = "dd-MM-yyyy") @Column(name = "payment_date", nullable = false) Date date; @Column(name = "description") String description; @Column(name = "bank_service") String bank_service; @ManyToOne(optional = false) @JoinColumn(name = "employee_id") Employee employee; }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package core.model.comparator; import core.model.Review; import java.util.Comparator; /** * * @author Rogerio */ public class ReviewImportanceComparator implements Comparator<Review>{ @Override public int compare(Review o1, Review o2) { if (o1.getImportancia() < o2.getImportancia()) { return -1; } if (o1.getImportancia() > o2.getImportancia()) { return 1; } return 0; } }
/* * Copyright: (c) 2004-2011 Mayo Foundation for Medical Education and * Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the * triple-shield Mayo logo are trademarks and service marks of MFMER. * * Except as contained in the copyright notice above, or as used to identify * MFMER as the author of this software, the trade names, trademarks, service * marks, or product names of the copyright holder shall not be used in * advertising, promotion or otherwise in connection with this software without * prior written authorization of the copyright holder. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package edu.mayo.cts2.framework.service.meta; import edu.mayo.cts2.framework.model.core.MatchAlgorithmReference; /** * The Enum StandardMatchAlgorithmReference. * * @author <a href="mailto:kevin.peterson@mayo.edu">Kevin Peterson</a> */ public enum StandardMatchAlgorithmReference { EXACT_MATCH ( "exactMatch", null, null ), CONTAINS ( "contains", null, null ), STARTS_WITH ( "startsWith", null, null ); private final MatchAlgorithmReference reference; /** * Instantiates a new standard match algorithm reference. * * @param name the name * @param uri the uri * @param href the href */ private StandardMatchAlgorithmReference(String name, String uri, String href){ MatchAlgorithmReference ref = new MatchAlgorithmReference(); ref.setContent(name); ref.setUri(uri); ref.setHref(href); this.reference = ref; } /** * Gets the match algorithm reference. * * @return the match algorithm reference */ public MatchAlgorithmReference getMatchAlgorithmReference(){ return this.reference; } }
package com.lebnutrition.lebnutrition; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class meal { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) int id; int maindish; int sidedish1 = -1; int sidedish2 = -1; int sidedish3 = -1; int sidedish4 = -1; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getMaindish() { return maindish; } public void setMaindish(int maindish) { this.maindish = maindish; } public int getSidedish1() { return sidedish1; } public void setSidedish1(int sidedish1) { this.sidedish1 = sidedish1; } public int getSidedish2() { return sidedish2; } public void setSidedish2(int sidedish2) { this.sidedish2 = sidedish2; } public int getSidedish3() { return sidedish3; } public void setSidedish3(int sidedish3) { this.sidedish3 = sidedish3; } public int getSidedish4() { return sidedish4; } public void setSidedish4(int sidedish4) { this.sidedish4 = sidedish4; } }
package com.tencent.mm.plugin.game.ui; import android.content.Intent; import android.view.MenuItem; import android.view.MenuItem.OnMenuItemClickListener; class GameCategoryUI$2 implements OnMenuItemClickListener { final /* synthetic */ GameCategoryUI jUT; GameCategoryUI$2(GameCategoryUI gameCategoryUI) { this.jUT = gameCategoryUI; } public final boolean onMenuItemClick(MenuItem menuItem) { Intent intent = new Intent(this.jUT, GameSearchUI.class); switch (GameCategoryUI.a(this.jUT)) { case 1: intent.putExtra("game_report_from_scene", 1602); break; case 2: intent.putExtra("game_report_from_scene", 1502); break; } this.jUT.startActivity(intent); return true; } }
package dev.televex.fhgcore; import dev.televex.fhgcore.commands.*; import dev.televex.fhgcore.listeners.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import java.io.File; import java.util.*; import java.util.logging.Level; import java.util.stream.Collectors; /** * All code Copyright (c) 2015 by Eric_1299. All Rights Reserved. */ public class core extends JavaPlugin { public static List<String> tps = new ArrayList<>(); public static List<String> tpa = new ArrayList<>(); public static List<Player> commands = new ArrayList<>(); public static List<Player> inv = new ArrayList<>(); public static List<Player> vanished = new ArrayList<>(); public static List<Player> spies = new ArrayList<>(); public static Map<Player, Location> backdata = new HashMap<>(); public static List<Player> dirt = new ArrayList<>(); public static List<Player> stone = new ArrayList<>(); public static List<Player> coal = new ArrayList<>(); public static List<Player> iron = new ArrayList<>(); public static List<Player> redstone = new ArrayList<>(); public static List<Player> lapis = new ArrayList<>(); public static List<Player> gold = new ArrayList<>(); public static List<Player> diamond = new ArrayList<>(); public static List<Player> emerald = new ArrayList<>(); public static List<Player> global = new ArrayList<>(); @Override public void onEnable() { initCmds(); initListeners(); initConfig(); timers.startTimers(); for(Player p: Bukkit.getOnlinePlayers()){ channels.setChannel(p, "Dirt"); p.sendMessage(tags.ytag+"You were switched to "+channels.getTag("Dirt")+"\u00A7E after the restart."); } } @Override public void onDisable() { this.saveConfig(); } public static void chatToConsole(String s){ Bukkit.getServer().getLogger().log(Level.INFO, ChatColor.stripColor(s)); } private void initConfig() { File f = new File(getDataFolder().toPath() + "config.yml"); if (!f.exists()) { this.saveDefaultConfig(); } } public static int randInt(int min, int max) { return new Random().nextInt((max - min) + 1) + min; } private void initCmds() { getCommand("rl").setExecutor(new util()); getCommand("channel").setExecutor(new channelsCMD()); getCommand("rlc").setExecutor(new util()); getCommand("reload").setExecutor(new util()); getCommand("rank").setExecutor(new rank()); getCommand("heal").setExecutor(new player()); getCommand("eat").setExecutor(new player()); getCommand("fix").setExecutor(new player()); getCommand("fly").setExecutor(new player()); getCommand("spawn").setExecutor(new player()); getCommand("shop").setExecutor(new player()); getCommand("setshop").setExecutor(new player()); getCommand("setspawn").setExecutor(new player()); getCommand("craft").setExecutor(new player()); getCommand("echest").setExecutor(new player()); getCommand("tp").setExecutor(new tp()); getCommand("commands").setExecutor(new commandsCMD()); getCommand("money").setExecutor(new money()); getCommand("sell").setExecutor(new sell()); getCommand("trail").setExecutor(new player()); getCommand("nick").setExecutor(new player()); getCommand("afk").setExecutor(new afkcmd()); getCommand("aflack").setExecutor(new afkcmd()); getCommand("inv").setExecutor(new inv()); getCommand("vanish").setExecutor(new vanish()); getCommand("v").setExecutor(new vanish()); getCommand("spy").setExecutor(new spy()); getCommand("broadcast").setExecutor(new chatCmd()); getCommand("bc").setExecutor(new chatCmd()); getCommand("warn").setExecutor(new chatCmd()); getCommand("spam").setExecutor(new chatCmd()); getCommand("name").setExecutor(new item()); getCommand("lore").setExecutor(new item()); getCommand("back").setExecutor(new back()); } private void initListeners() { Bukkit.getServer().getPluginManager().registerEvents(new traffic(), this); Bukkit.getServer().getPluginManager().registerEvents(new commandsListener(), this); Bukkit.getServer().getPluginManager().registerEvents(new timers(), this); Bukkit.getServer().getPluginManager().registerEvents(new spyListener(), this); Bukkit.getServer().getPluginManager().registerEvents(new vanishListener(), this); Bukkit.getServer().getPluginManager().registerEvents(new backListener(), this); Bukkit.getServer().getPluginManager().registerEvents(new help(), this); Bukkit.getServer().getPluginManager().registerEvents(new channels(), this); } public static String getRealName(Player p) { String prefix = ""; switch (rank.getRank(p)) { case OP: prefix = "\u00A77\u00A7L[\u00A74\u00A7LOP\u00A77\u00A7L] \u00A7r"; break; case MOD: prefix = "\u00A77\u00A7L[\u00A75\u00A7LMOD\u00A77\u00A7L] \u00A7r"; break; case VIP: prefix = "\u00A77\u00A7L[\u00A73\u00A7LVIP\u00A77\u00A7L] \u00A7r"; break; case USER: prefix = "\u00A77\u00A7L[\u00A76\u00A7LUSER\u00A77\u00A7L] \u00A7r"; break; } return prefix + p.getDisplayName(); } public static void sendBuildInfo(Player p){ p.sendMessage(tags.ptag + tags.pb + "========== " + tags.fhg + tags.pb + "=========="); p.sendMessage(tags.ptag + "Running \u00A76FHGCore \u00A7dv0.0.6"); p.sendMessage(tags.ptag + "Author: Televex (aka Eric_1299)"); p.sendMessage(tags.ptag + tags.pb + "==================================="); } public static List<String> buildHelp(String cmd, Map<String, String> args, String desc){ List<String> helpMenu = new ArrayList<>(); helpMenu.add(tags.ptag + tags.pb + "USAGE: /" + cmd); helpMenu.add(tags.ptag + "/" + cmd + "\u00A78: \u00A77" + desc); helpMenu.addAll(args.keySet().stream().map(s -> tags.ptag + "/" + cmd + " " + s + "\u00A78: \u00A77" + args.get(s)).collect(Collectors.toList())); return helpMenu; } public static String buildList(String init, List<String> values) { int i = values.size(); for (String e : values) { i--; if (i == 0) { init += e + "."; } else { init += e + ", "; } } return init; } }
/* * [y] hybris Platform * * Copyright (c) 2000-2016 SAP SE * All rights reserved. * * This software is the confidential and proprietary information of SAP * Hybris ("Confidential Information"). You shall not disclose such * Confidential Information and shall use it only in accordance with the * terms of the license agreement you entered into with SAP Hybris. */ package com.cnk.travelogix.core.flightview.datamodels; public class UpdateDeliverUrlRequest { protected String deliveryUrl; /** * @return the deliveryUrl */ public String getDeliveryUrl() { return deliveryUrl; } /** * @param deliveryUrl * the deliveryUrl to set */ public void setDeliveryUrl(String deliveryUrl) { this.deliveryUrl = deliveryUrl; } }
package com.jin.kafka.logstash; /** * @author wu.jinqing * @date 2017年12月05日 */ public class AccessLog { private String tranCode; private String crtDt; private String msg; public AccessLog(String tranCode, String crtDt, String msg) { this.tranCode = tranCode; this.crtDt = crtDt; this.msg = msg; } public String getTranCode() { return tranCode; } public void setTranCode(String tranCode) { this.tranCode = tranCode; } public String getCrtDt() { return crtDt; } public void setCrtDt(String crtDt) { this.crtDt = crtDt; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } }
package com.blackvelvet.cybos.bridge.cputil ; import com4j.*; /** */ public enum CPE_ECT_ELW_RIGHT_TYPE { /** * <p> * 표준옵션 * </p> * <p> * The value of this constant is 0 * </p> */ CPT_ELW_RIGHT_STANDARD, // 0 /** * <p> * 디지털옵션 * </p> * <p> * The value of this constant is 1 * </p> */ CPT_ELW_RIGHT_DIGITAL, // 1 /** * <p> * 조기종료 * </p> * <p> * The value of this constant is 2 * </p> */ CPT_ELW_RIGHT_KOBA, // 2 }
package com.encore.child; import com.encore.parent.Employee; import com.encore.util.MyDate; /* * 부모 클래스 Employee로부터 모든것을 물려받고 * 자기자신만의 멤버를 추가하는 자식클래스... * * 생성자 호출 ---> 객체 생성 */ public class Manager extends Employee{//Employee에서 기본생성자를 꼭 만들어야 한다. //자식만의 멤버를 추가 private String dept; /* * 자식생성자... 객체 생성알고리즘 * 자식 생성자 { 첫라인에서 무조건 부모 기본생성자 호출이 일어난다} */ public Manager(String name, MyDate birthDay, double salary, String dept) {//자식이 생성되려할때... //무조건 부모 기본생성자 호출...super(); super(name, birthDay, salary); this.dept = dept; } //Method Overriding /* * 상속관계에서만 일어난다. * Step 1 : 부모가 가진 기능을 물려받는다...호출한다 * Step 2 : 그걸 자신에 맞게 고쳐쓴다. * * Overriding의 Rule * 0. 상속관계의 두 클래스 사이에서 일어난다 * 1. 메소드 선언부는 모두 일치 * 2. 구현부는 반드시 달라야 한다 * --> 이름은 같지만 하는일이 달라졌으므로 새로운 메소드가 만들어졌다. * */ @Override public String toString() { return super.toString()+","+dept; } }
package org.newdawn.slick; import org.newdawn.slick.opengl.SlickCallable; import org.newdawn.slick.opengl.renderer.Renderer; import org.newdawn.slick.opengl.renderer.SGL; public class ScalableGame implements Game { private static SGL GL = Renderer.get(); private float normalWidth; private float normalHeight; private Game held; private boolean maintainAspect; private int targetWidth; private int targetHeight; private GameContainer container; public ScalableGame(Game held, int normalWidth, int normalHeight) { this(held, normalWidth, normalHeight, false); } public ScalableGame(Game held, int normalWidth, int normalHeight, boolean maintainAspect) { this.held = held; this.normalWidth = normalWidth; this.normalHeight = normalHeight; this.maintainAspect = maintainAspect; } public void init(GameContainer container) throws SlickException { this.container = container; recalculateScale(); this.held.init(container); } public void recalculateScale() throws SlickException { this.targetWidth = this.container.getWidth(); this.targetHeight = this.container.getHeight(); if (this.maintainAspect) { boolean normalIsWide = ((this.normalWidth / this.normalHeight) > 1.6D); boolean containerIsWide = ((this.targetWidth / this.targetHeight) > 1.6D); float wScale = this.targetWidth / this.normalWidth; float hScale = this.targetHeight / this.normalHeight; if (normalIsWide & containerIsWide) { float scale = (wScale < hScale) ? wScale : hScale; this.targetWidth = (int)(this.normalWidth * scale); this.targetHeight = (int)(this.normalHeight * scale); } else if ((normalIsWide & (containerIsWide ? 0 : 1)) != 0) { this.targetWidth = (int)(this.normalWidth * wScale); this.targetHeight = (int)(this.normalHeight * wScale); } else if (((normalIsWide ? 0 : 1) & containerIsWide) != 0) { this.targetWidth = (int)(this.normalWidth * hScale); this.targetHeight = (int)(this.normalHeight * hScale); } else { float scale = (wScale < hScale) ? wScale : hScale; this.targetWidth = (int)(this.normalWidth * scale); this.targetHeight = (int)(this.normalHeight * scale); } } if (this.held instanceof InputListener) this.container.getInput().addListener((InputListener)this.held); this.container.getInput().setScale(this.normalWidth / this.targetWidth, this.normalHeight / this.targetHeight); int yoffset = 0; int xoffset = 0; if (this.targetHeight < this.container.getHeight()) yoffset = (this.container.getHeight() - this.targetHeight) / 2; if (this.targetWidth < this.container.getWidth()) xoffset = (this.container.getWidth() - this.targetWidth) / 2; this.container.getInput().setOffset(-xoffset / this.targetWidth / this.normalWidth, -yoffset / this.targetHeight / this.normalHeight); } public void update(GameContainer container, int delta) throws SlickException { if (this.targetHeight != container.getHeight() || this.targetWidth != container.getWidth()) recalculateScale(); this.held.update(container, delta); } public final void render(GameContainer container, Graphics g) throws SlickException { int yoffset = 0; int xoffset = 0; if (this.targetHeight < container.getHeight()) yoffset = (container.getHeight() - this.targetHeight) / 2; if (this.targetWidth < container.getWidth()) xoffset = (container.getWidth() - this.targetWidth) / 2; SlickCallable.enterSafeBlock(); g.setClip(xoffset, yoffset, this.targetWidth, this.targetHeight); GL.glTranslatef(xoffset, yoffset, 0.0F); g.scale(this.targetWidth / this.normalWidth, this.targetHeight / this.normalHeight); GL.glPushMatrix(); this.held.render(container, g); GL.glPopMatrix(); g.clearClip(); SlickCallable.leaveSafeBlock(); renderOverlay(container, g); } protected void renderOverlay(GameContainer container, Graphics g) {} public boolean closeRequested() { return this.held.closeRequested(); } public String getTitle() { return this.held.getTitle(); } } /* Location: C:\Users\BSV\AppData\Local\Temp\Rar$DRa6216.20396\Preview\Preview.jar!\org\newdawn\slick\ScalableGame.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */
package com.automician.core.locators; import org.openqa.selenium.By; import java.util.ArrayList; import java.util.List; public class Locators { public static By attrValue(String attrName, String attrValue) { return By.cssSelector(getAttrValueSelector(attrName, attrValue)); } public static By attrValueStarts(String attrName, String attrValue) { return By.cssSelector(getAttrValueSelector(attrName, attrValue, "^=")); } public static By oneOfAttrValues(String attrName, String... attrValues) { List<String> cssSelectors = new ArrayList<>(); for (String attrValue : attrValues) { cssSelectors.add(getAttrValueSelector(attrName, attrValue)); } return By.cssSelector(String.join(",", cssSelectors)); } //xpath = //*[@attrName='some value 1' or @attrName='some value 2']/.. //get elements with attr attrName and next get their parent public static By childHasOneOfAttrValues(String attrName, String... attrValues) { List<String> attrConditions = new ArrayList<>(); for (String attrValue : attrValues) { attrConditions.add("@" + attrName + "='" + attrValue + "'"); } return By.xpath("//*[" + String.join(" or ", attrConditions) + "]/.."); } private static String getAttrValueSelector(String attrName, String attrValue) { return getAttrValueSelector(attrName, attrValue, "="); } private static String getAttrValueSelector(String attrName, String attrValue, String operator) { return "[" + attrName + operator + "'" + attrValue + "']"; } }
package listing; public class MochaListing extends AbstractListing{ private static final String TESTS_FOLDER = "/test/"; private static final String TESTS_EXTENSION = "js"; public MochaListing(String projectPath){ super(projectPath, TESTS_FOLDER, TESTS_EXTENSION); } }
package com.mx.profuturo.bolsa.model.reports.vo.data; import com.mx.profuturo.bolsa.model.reports.response.HiringsResponse; import com.mx.profuturo.bolsa.model.reports.response.RecruitmentSourcesResponse; public class FuentesReclutamientoVO extends DatosFiltrosVO { private String fecha; private String status; private String fuente; private String candidato; public FuentesReclutamientoVO() { // TODO Auto-generated constructor stub } public FuentesReclutamientoVO(RecruitmentSourcesResponse e) { super(e); this.status = e.getEstatus(); this.fuente = e.getFuente(); this.candidato = e.getCandidato(); this.fecha = e.getFecha(); } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getFuente() { return fuente; } public void setFuente(String fuente) { this.fuente = fuente; } public String getCandidato() { return candidato; } public void setCandidato(String candidato) { this.candidato = candidato; } public String getFecha() { return fecha; } public void setFecha(String fecha) { this.fecha = fecha; } }
// 1. 实现一个方法,传入一个文件名filename与一个字符串,将字符串写入到本文件夹的文件filename中 import java.io.File; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class one{ public static void main(String[] args) { String filename = "test"; String str = "Hello world"; writeIntoFile(filename, str); } public static void writeIntoFile(String filename, String str){ try{ File writename = new File(filename + ".txt"); writename.createNewFile(); BufferedWriter out = new BufferedWriter(new FileWriter(writename)); out.write(str); out.flush(); out.close(); }catch(IOException e){ e.printStackTrace(); } } }
package pl.asie.endernet.util; import java.io.IOException; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTSizeTracker; public class PortableItemStack { private String itemName; private int damage, quantity; private byte[] nbtData; public PortableItemStack(ItemStack is) throws IOException, UnsupportedItemStackException { this.itemName = Item.itemRegistry.getNameForObject(is.getItem()); this.damage = is.getItemDamage(); this.quantity = is.stackSize; if(is.hasTagCompound()) this.nbtData = CompressedStreamTools.compress(is.getTagCompound()); } public ItemStack toItemStack() throws IOException { ItemStack is = new ItemStack((Item)Item.itemRegistry.getObject(itemName), quantity, damage); if(nbtData != null && nbtData.length > 0) is.setTagCompound(CompressedStreamTools.func_152457_a(nbtData, new NBTSizeTracker(2097152L))); return is; } }
package co.nos.noswallet.ui.home.v2; import java.util.ArrayList; import co.nos.noswallet.network.nosModel.AccountHistory; import co.nos.noswallet.persistance.IndexedWallet; public interface CurrencyView { boolean isNotAttached(); void showHistory(ArrayList<AccountHistory> history); void onBalanceFormattedReceived(String formatted); void showNewAccount(); void navigateToTransactionEntry(AccountHistory accountHistory, IndexedWallet wallet); void onVersusBalanceReceived(String equivalent); }
package br.udesc.controller; import br.udesc.model.dao.CursoJpaController; import br.udesc.model.dao.DisciplinaJpaController; import br.udesc.model.dao.RestricaoDisciplinaJpaController; import br.udesc.model.entidade.Disciplina; import br.udesc.model.entidade.PessoaHorarioPreferencia; import br.udesc.model.entidade.RestricaoDisciplina; import br.udesc.view.TelaRestricoesDisciplina; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.JComboBox; import javax.swing.JOptionPane; /** * Classe resposável por realizar o controle da tela * "TelaRestricoesDisciplina.java". Este módulo permite o usuário definir restrições * para cada disciplina. Estas restrições se baseiam na obrigação ou na * proibição de a disciplina ser lecionada em dias específicos da semana. Cada * dia da semana é divido em primeiro e segundo horário. * @author PIN2 */ public class ControladorTelaRestricoesDisciplina { private TelaRestricoesDisciplina trd; private Disciplina dis; private DisciplinaJpaController djc; private RestricaoDisciplinaJpaController rdjc; private JComboBox[][] restricoes; private List<RestricaoDisciplina> restricoesAntigas; private List<RestricaoDisciplina> restricoesNovas; private int qtTotalRestricoes; private ControladorTelaInicio cti; /** * Construtor intanciando os objetos necessários e iniciando os componentes da Tela. * @param id Id da disciplina na qual as restrições se referem. */ public ControladorTelaRestricoesDisciplina(long id) { cti = new ControladorTelaInicio(); trd = new TelaRestricoesDisciplina(); dis = new Disciplina(); djc = new DisciplinaJpaController(); rdjc = new RestricaoDisciplinaJpaController(); this.buscaDisciplina(id); carregaListaCbxRestricoes(); carregaListaCbxRestricoesDisciplina(); carregaLabel(); iniciar(); } /** * Método que inicia os componentes do JFrame (Botões etc). */ public void iniciar() { /* Define as ações que serão realizadas a partir do clique no botão "Salvar" */ trd.botaoSalvar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { /* Salva as restrições definidas na tela no array "restricoesNovas" */ salvarRestricoes(); /* Remove-se do banco as restrições antigas para a disciplina em questão */ removerRestricoesAntigas(); /* Insere-se no banco as novas restrições para esta disciplina */ persistirRestricoes(); JOptionPane.showMessageDialog(null, "Restrições salvas com sucesso", "Sucesso", JOptionPane.INFORMATION_MESSAGE); cti.executar(); trd.dispose(); } }); /* Define as ações que serão realizadas a partir do clique no botão "Cancelar" */ trd.botaoCancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { /* Fecha-se a tela atual */ cti.executar(); trd.dispose(); } }); trd.botaoInicio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ControladorTelaInicio cti = new ControladorTelaInicio(); cti.executar(); executar(); trd.dispose(); } }); trd.botaoProfessor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ControladorTelaTableProfessor cttp = new ControladorTelaTableProfessor(); cttp.executar(); trd.setVisible(false); } }); trd.botaoSala.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ControladorTelaTableSala cts = new ControladorTelaTableSala(); cts.executar(); trd.setVisible(false); } }); trd.botaoDisciplina.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { CursoJpaController cjc = new CursoJpaController(); if (cjc.getCursoCount() != 0) { ControladorTelaTableDisciplina cttd = new ControladorTelaTableDisciplina(); cttd.executar(); trd.setVisible(false); } else { JOptionPane.showMessageDialog(null, "Antes cadastre um curso", "Cadastre um curso", JOptionPane.INFORMATION_MESSAGE); } } }); trd.botaoCurso.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ControladorTelaTableCurso cttc = new ControladorTelaTableCurso(); cttc.executar(); trd.setVisible(false); } }); trd.botaoVincular.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ControladorTelaVinculo ctr = new ControladorTelaVinculo(); ctr.executar(); trd.setVisible(false); } }); } /** * Método resposável por adicionar a opções disponíveis de cada ComboBox de * restrição, que é: "Obrigatório" ou "Proibido". * Existe uma matriz de ComboBox na qual a posição "x" da matriz se refere * ao dia da semana, e a posição "y" ao período do dia na qual a restrição * será aplicada conforme abaixo: * Dias da semana: * Segunda-feira: 1 * Terça-feira: 2 * Quarta-feira: 3 * Quinta-feira: 4 * Sexta-feira: 5 * Sábado: 6 * Períodos: * 1º Período: 1 * 2º Período: 2 * * Exemplo: Terça-feira no primeiro horário recebe o valor "21". */ public void carregaListaCbxRestricoes() { restricoes = new JComboBox[6][2]; restricoes[0][0] = trd.cbxSegunda1; restricoes[0][1] = trd.cbxSegunda2; restricoes[1][0] = trd.cbxTerca1; restricoes[1][1] = trd.cbxTerca2; restricoes[2][0] = trd.cbxQuarta1; restricoes[2][1] = trd.cbxQuarta2; restricoes[3][0] = trd.cbxQuinta1; restricoes[3][1] = trd.cbxQuinta2; restricoes[4][0] = trd.cbxSexta1; restricoes[4][1] = trd.cbxSexta2; restricoes[5][0] = trd.cbxSabado1; restricoes[5][1] = trd.cbxSabado2; for (int i = 0; i < restricoes.length; i++) { for (int j = 0; j < 2; j++) { restricoes[i][j].addItem(" "); restricoes[i][j].addItem("Obrigatório"); restricoes[i][j].addItem("Proibido"); } } } /** * Método responsável por carregar as restrições já existentes para a * disciplina nos ComboBox's. */ public void carregaListaCbxRestricoesDisciplina() { for (RestricaoDisciplina p : restricoesAntigas) { String seq = String.valueOf(p.getHorario()); /* Armazena-se o primeiro caractere da variável "horario" do objeto "RestricaoDisciplina" que se trata do dia da semana*/ String diaAux = String.valueOf(seq.charAt(0)); int dia = Integer.parseInt(diaAux); /* Armazena-se o segundo caractere da variável "horario" do objeto "RestricaoDisciplina" que se trata do período do dia */ String horarioAux = String.valueOf(seq.charAt(1)); int horario = Integer.parseInt(horarioAux); /* Define o valor atual para o ComboBox referente ao dia/período em questão */ if (p.getCondicao() == 3) { restricoes[dia - 1][horario - 1].setSelectedIndex(p.getCondicao() - 1); } else { restricoes[dia - 1][horario - 1].setSelectedIndex(p.getCondicao()); } } } /** * Método responsável por adicionar as restrições que estão definidas na * tela para o array "novasRestrições" que serão atualizadas para a disciplina. */ public void salvarRestricoes() { RestricaoDisciplina ph; restricoesNovas = new ArrayList<RestricaoDisciplina>(); /* Percorre-se a matriz verificando qual foi o valor definido pelo usuário */ for (int i = 0; i < restricoes.length; i++) { for (int j = 0; j < 2; j++) { if (restricoes[i][j].getSelectedItem().equals("Obrigatório")) { ph = new RestricaoDisciplina(); String seq = String.valueOf(i + 1) + String.valueOf(j + 1); ph.setHorario(Integer.parseInt(seq)); /* Obrigatório recebe valor 1 */ ph.setCondicao(1); ph.setDisciplina(this.dis); restricoesNovas.add(ph); } else if (restricoes[i][j].getSelectedItem().equals("Proibido")) { ph = new RestricaoDisciplina(); String seq = String.valueOf(i + 1) + String.valueOf(j + 1); ph.setHorario(Integer.parseInt(seq)); /* Obrigatório recebe valor 1 */ ph.setCondicao(3); ph.setDisciplina(this.dis); restricoesNovas.add(ph); } } } } /** * Método responsável por salvar as novas restrições no banco de dados. */ public void persistirRestricoes() { for (RestricaoDisciplina p : restricoesNovas) { try { rdjc.create(p); } catch (Exception e) { e.printStackTrace(); } } } /** * Método responsável por remover do banco de dados as antigas restrições da * disciplina. */ public void removerRestricoesAntigas() { for (RestricaoDisciplina p : restricoesAntigas) { try { rdjc.destroy(p.getId()); } catch (Exception e) { e.printStackTrace(); } } } /** * Método responsável por inicializar a tela controlada por esta classe. */ public void executar() { trd.setVisible(true); } /** * Método responsável por buscar a disciplina com "id" definida no parâmetro * e salvar na variável aqui instanciada. * @param id Id da disciplina na qual se refere. */ public void buscaDisciplina(long id) { this.dis = djc.findDisciplina(id); this.restricoesAntigas = rdjc.buscarRestricoes(id); } /** * Método responsável por carregar o nome da disciplina em questão no * cabeçalho da tela. */ public void carregaLabel() { trd.labelTitulo.setText("Restrições para " + this.dis.getNome()); } }
package ns.Server; import java.net.Socket; import java.net.ServerSocket; import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; public class Server extends ServerSocket { public static final int DEFAULT_PORT = 6052; public Server() throws IOException { super(); } public Server(int port) throws IOException { super(port); } public static void main(String[] args) { int port = DEFAULT_PORT; if (args.length > 0) { port = Integer.parseInt(args[0]); } Server instance = null; try { instance = new Server(port); } catch (IOException e) { System.err.println("Could not create server: " + e.getMessage()); return; } System.out.println("Server running on " + port); while (true) { Socket sock; try { sock = instance.accept(); } catch (IOException e) { System.err.println("Could not accept connection: " + e.getMessage()); return; } Runnable task = new Connection(sock); task.run(); } } }
package cn.bs.zjzc.presenter; import cn.bs.zjzc.App; import cn.bs.zjzc.model.IOftenAddressModel; import cn.bs.zjzc.model.bean.EditAddressRequestBody; import cn.bs.zjzc.model.callback.HttpTaskCallback; import cn.bs.zjzc.model.impl.OftenAddressModel; import cn.bs.zjzc.model.response.BaseResponse; import cn.bs.zjzc.ui.view.IOftenAddressComplementView; /** * Created by Ming on 2016/6/28. */ public class OftenAddressComplementPresenter { private IOftenAddressComplementView mInfoComplementView; private IOftenAddressModel mInfoComplementModel; public OftenAddressComplementPresenter(IOftenAddressComplementView infoComplementView) { mInfoComplementView = infoComplementView; mInfoComplementModel = new OftenAddressModel(mInfoComplementView.getContext(), App.LOGIN_USER.getAccount()); } public void editOftenAddress(EditAddressRequestBody requestBody, String city) { mInfoComplementView.showLoading(); mInfoComplementModel.editOftenAddress(requestBody, city, new HttpTaskCallback<BaseResponse>() { @Override public void onTaskFailed(String errorInfo) { mInfoComplementView.hideLoading(); mInfoComplementView.showMsg(errorInfo); } @Override public void onTaskSuccess(BaseResponse data) { mInfoComplementView.hideLoading(); mInfoComplementView.showEditSuccess(); } }); } }
package com.mdb; import static com.mdb.ServerMain.endPoints; import static com.mdb.ServerMain.queueProcessors; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import lombok.extern.slf4j.Slf4j; import java.io.IOException; @Slf4j public class HandlerMain implements HttpHandler { public void handle(HttpExchange h) throws IOException { try { String path = h.getHttpContext().getPath(); QueueProcessor qp = queueProcessors.get(endPoints.get(path)); synchronized (qp.requests) { qp.requests.add(h); qp.queueEvent.signal(); //log.info(qp.name + " queue size: " + qp.requests.size()); } } catch (Exception e) { log.error("HandlerMain problem", e); } } }
package com.github.chiamingmai.networkmanagerdemo; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.text.method.HideReturnsTransformationMethod; import android.text.method.PasswordTransformationMethod; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import android.widget.ToggleButton; import com.github.chiamingmai.networkmanager.NetworkManager; public class WiFiHotspotFragment extends MyFragment { ViewHolder viewHolder; BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case MainActivity.HOTSPOT_ENABLED: Toast.makeText(context, "HOTSPOT_ENABLED", Toast.LENGTH_LONG).show(); getStatus(); break; case MainActivity.HOTSPOT_DISABLED: Toast.makeText(context, "HOTSPOT_DISABLED", Toast.LENGTH_LONG).show(); getStatus(); break; case MainActivity.HOTSPOT_CLIENT: String[] clientInfo = intent.getStringArrayExtra(MainActivity.HOTSPOT_CLIENT); getStatus(); viewHolder.tvStatus.append("Connected Clients: " + MainActivity.seperator); int len = clientInfo.length; for (int i = 0; i < len; i++) { viewHolder.tvStatus.append(clientInfo[i]); } break; default: break; } } }; public static class ViewHolder { TextView tvStatus = null; ToggleButton networkSwitch = null; Button btnGetClient = null; CheckBox cBShowPwd = null; EditText eTSSID = null; EditText eTPassword = null; } @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true); final View view = inflater.inflate(R.layout.wifihotspot_frag_layout, container, false); Object tag = view.getTag(); if (tag != null && tag instanceof ViewHolder) { viewHolder = (ViewHolder) tag; } else { viewHolder = new ViewHolder(); ToggleButton networkBtn = (ToggleButton) view.findViewById(R.id.networkswitch); networkBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { String SSID = viewHolder.eTSSID.getText().toString(); String pwd = viewHolder.eTPassword.getText().toString(); if (!"".equals(SSID) && !"".equals(pwd)) MainActivity.networkManager.createWifiHotspot(SSID, pwd); else { Toast.makeText(MainActivity.ctx, "Please enter SSID and Password", Toast.LENGTH_LONG).show(); viewHolder.networkSwitch.setChecked(false); } } else { MainActivity.networkManager.disableNetworkInterface(NetworkManager.NetworkType.WIFI_HOTSPOT); } } }); viewHolder.networkSwitch = networkBtn; TextView tvStatus = (TextView) view.findViewById(R.id.tvStatus); tvStatus.setMovementMethod(new ScrollingMovementMethod()); viewHolder.tvStatus = tvStatus; Button btnGetClient = (Button) view.findViewById(R.id.btnGetClient); btnGetClient.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MainActivity.networkManager.getWifiHotspotClientList(); } }); viewHolder.btnGetClient = btnGetClient; CheckBox cBShowPwd = (CheckBox) view.findViewById(R.id.cBShowPwd); cBShowPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { viewHolder.eTPassword.setTransformationMethod(new HideReturnsTransformationMethod()); } else { viewHolder.eTPassword.setTransformationMethod(new PasswordTransformationMethod()); } } }); viewHolder.cBShowPwd = cBShowPwd; viewHolder.eTSSID = (EditText) view.findViewById(R.id.eTSSID); viewHolder.eTPassword = (EditText) view.findViewById(R.id.eTPassword); view.setTag(viewHolder); } viewHolder.networkSwitch.setChecked(MainActivity.networkManager.isNetworkEnabled(NetworkManager.NetworkType.WIFI_HOTSPOT)); viewHolder.eTSSID.setText(null); viewHolder.eTPassword.setText(null); viewHolder.cBShowPwd.setChecked(false); getStatus(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(MainActivity.MOBILE_ENABLED); intentFilter.addAction(MainActivity.MOBILE_CONNECTED); intentFilter.addAction(MainActivity.HOTSPOT_CLIENT); MainActivity.ctx.registerReceiver(receiver, intentFilter); return view; } void getStatus() { StringBuilder str = new StringBuilder(); str.append("isWiFiHotspotEnabled: " + MainActivity.networkManager.isNetworkEnabled(NetworkManager.NetworkType.WIFI_HOTSPOT)); str.append(MainActivity.seperator + MainActivity.seperator); viewHolder.tvStatus.setText(str.toString()); } @Override public void onDetach() { super.onDetach(); viewHolder = null; MainActivity.ctx.unregisterReceiver(receiver); } }
package com.training.java.stream; public class EmployeeReduceObject { private int weight; private int height; private StringBuffer name = new StringBuffer(); private StringBuffer surname = new StringBuffer(); public static EmployeeReduceObject comb(final EmployeeReduceObject a, final EmployeeReduceObject b) { EmployeeReduceObject sum = new EmployeeReduceObject(); sum.weight = a.weight + b.weight; sum.height = a.height + b.height; sum.name.append(a.getName()); sum.name.append(b.getName()); sum.surname.append(a.getSurname()); sum.surname.append(b.getSurname()); return sum; } public EmployeeReduceObject acum(final Employee employee) { this.weight += employee.getWeight(); this.height += employee.getHeight(); this.name.append(employee.getName()); this.surname.append(employee.getSurname()); return this; } public int getWeight() { return this.weight; } public void setWeight(final int weightParam) { this.weight = weightParam; } public int getHeight() { return this.height; } public void setHeight(final int heightParam) { this.height = heightParam; } public StringBuffer getName() { return this.name; } public void setName(final StringBuffer nameParam) { this.name = nameParam; } public StringBuffer getSurname() { return this.surname; } public void setSurname(final StringBuffer surnameParam) { this.surname = surnameParam; } @Override public String toString() { return "EmployeeReduceObject [weight=" + this.weight + ", height=" + this.height + ", name=" + this.name + ", surname=" + this.surname + "]"; } }
package com.tencent.mm.plugin.remittance.ui; import com.tencent.mm.g.a.fo; import com.tencent.mm.plugin.report.service.h; import com.tencent.mm.sdk.b.b; import com.tencent.mm.sdk.b.c; class RemittanceBaseUI$11 extends c<fo> { final /* synthetic */ RemittanceBaseUI mzz; RemittanceBaseUI$11(RemittanceBaseUI remittanceBaseUI) { this.mzz = remittanceBaseUI; this.sFo = fo.class.getName().hashCode(); } public final /* synthetic */ boolean a(b bVar) { fo foVar = (fo) bVar; if (foVar.bNX.bOa == 1) { h.mEJ.h(15386, new Object[]{Integer.valueOf(4), Integer.valueOf(1)}); } else { h.mEJ.h(15386, new Object[]{Integer.valueOf(5), Integer.valueOf(1)}); } String str = foVar.bNX.bNY; if (this.mzz.myU == 33) { this.mzz.a(this.mzz.cZG, this.mzz.mzh, str, foVar); } else { this.mzz.a(this.mzz.cZG, null, str, foVar); } return false; } }
package it.unica.pr2.ricercatori; import java.util.*; import java.lang.*; public class AutoreMancante extends RuntimeException{ public Ricercatore autoreMancante; public AutoreMancante(Ricercatore autoreMancante){ this.autoreMancante = autoreMancante; } }
package com.xuecheng.manage_course.dao; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.xuecheng.framework.domain.course.CourseBase; import com.xuecheng.framework.domain.course.ext.CourseInfo; import com.xuecheng.framework.domain.course.request.CourseListRequest; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; import java.util.Optional; @SpringBootTest @RunWith(SpringRunner.class) public class CourseMapperTest { @Autowired private CourseBaseRepository courseBaseRepository; @Autowired private CourseMapper courseMapper; @Test public void findCourseBaseById() { Optional<CourseBase> optional = courseBaseRepository.findById("297e7c7c62b888f00162b8a7dec20000"); if (optional.isPresent()) { CourseBase courseBase = optional.get(); System.out.println(courseBase); } } @Test public void findCourseBaseByIdMapper() { CourseBase courseBase = courseMapper.findCourseBaseById("297e7c7c62b888f00162b8a7dec20000"); if (courseBase != null) { System.out.println(courseBase); } } //测试分页 @Test public void testPageHelper(){ PageHelper.startPage(2, 1); CourseListRequest courseListRequest = new CourseListRequest(); List<CourseInfo> courseInfoList = courseMapper.findCourseListPage(courseListRequest); PageInfo<CourseInfo> pageInfo = PageInfo.of(courseInfoList); System.out.println(pageInfo.getTotal()); } }
package br.com.caiopaulucci; public class Gritador { public String shout(String s) { return s.toUpperCase().concat("!!!"); } }
package edu.buet.cse.spring.ch07.v2.util; public class AttributeNames { public static final String USER_ATTRIBUTE_NAME = "user"; private AttributeNames() { } }
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package view.game; import java.util.HashMap; import java.util.Map; import javax.swing.JLabel; /** * * @author sergi */ public class GamePanel extends javax.swing.JPanel { private GamePanelController controller; private Map<Integer, JLabel[]> hashMapPlayersCards =new HashMap<>(); private JLabel[] timeUserLabel; /** * Creates new form GamePanel */ private GamePanel() { initComponents(); } public GamePanel(GamePanelController controller){ this(); this.controller = controller; disableLabel(); //JLabel Cartas do usuário 0 (LOGGED) hashMapPlayersCards.put(0, new JLabel[]{ card_u0_c0, card_u0_c1, card_u0_c2, card_u0_c3, card_u0_c4, card_u0_c5, card_u0_c6 }); //JLabel Cartas do usuário 1 (ESQUERDA) hashMapPlayersCards.put(1, new JLabel[]{ card_u1_c0, card_u1_c1, card_u1_c2, card_u1_c3, card_u1_c4, card_u1_c5, card_u1_c6 }); //JLabel Cartas do usuário 2 (CIMA) hashMapPlayersCards.put(2, new JLabel[]{ card_u2_c0, card_u2_c1, card_u2_c2, card_u2_c3, card_u2_c4, card_u2_c5, card_u2_c6 }); //JLabel Cartas do usuário 3 (DIREITA) hashMapPlayersCards.put(3, new JLabel[]{ card_u3_c0, card_u3_c1, card_u3_c2, card_u3_c3, card_u3_c4, card_u3_c5, card_u3_c6 }); //JLabel Cartas (CARTAS DE INICIO) hashMapPlayersCards.put(4, new JLabel[]{ card_u0_start, card_u1_start, card_u2_start, card_u3_start }); //JLabel Cartas icones de ativo hashMapPlayersCards.put(5, new JLabel[]{ active_u0, active_u1, active_u2, active_u3 }); timeUserLabel = new JLabel[]{ txt_time_u0, txt_time_u1, txt_time_u2, txt_time_u3 }; } public JLabel[] getLabels(int userIndex){ return hashMapPlayersCards.get(userIndex); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel3 = new javax.swing.JPanel(); jPanel18 = new javax.swing.JPanel(); jPanel19 = new javax.swing.JPanel(); jPanel13 = new javax.swing.JPanel(); icon_u1 = new javax.swing.JLabel(); active_u1 = new javax.swing.JLabel(); card_u1_c0 = new javax.swing.JLabel(); card_u1_c1 = new javax.swing.JLabel(); card_u1_c2 = new javax.swing.JLabel(); card_u1_c3 = new javax.swing.JLabel(); card_u1_c4 = new javax.swing.JLabel(); card_u1_c5 = new javax.swing.JLabel(); card_u1_c6 = new javax.swing.JLabel(); card_u1_start = new javax.swing.JLabel(); txt_time_u1 = new javax.swing.JLabel(); jPanel20 = new javax.swing.JPanel(); btnOut = new javax.swing.JButton(); jPanel6 = new javax.swing.JPanel(); jPanel9 = new javax.swing.JPanel(); jPanel10 = new javax.swing.JPanel(); icon_u2 = new javax.swing.JLabel(); active_u2 = new javax.swing.JLabel(); card_u2_c0 = new javax.swing.JLabel(); card_u2_c1 = new javax.swing.JLabel(); card_u2_c2 = new javax.swing.JLabel(); card_u2_c3 = new javax.swing.JLabel(); card_u2_c4 = new javax.swing.JLabel(); card_u2_c5 = new javax.swing.JLabel(); card_u2_c6 = new javax.swing.JLabel(); card_u2_start = new javax.swing.JLabel(); txt_time_u2 = new javax.swing.JLabel(); panel = new javax.swing.JPanel(); panelTable = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); discard_1 = new javax.swing.JLabel(); discard_2 = new javax.swing.JLabel(); discard_3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); jPanel11 = new javax.swing.JPanel(); icon_u0 = new javax.swing.JLabel(); active_u0 = new javax.swing.JLabel(); card_u0_c0 = new javax.swing.JLabel(); card_u0_c1 = new javax.swing.JLabel(); card_u0_c2 = new javax.swing.JLabel(); card_u0_c3 = new javax.swing.JLabel(); card_u0_c4 = new javax.swing.JLabel(); card_u0_c5 = new javax.swing.JLabel(); card_u0_c6 = new javax.swing.JLabel(); card_u0_start = new javax.swing.JLabel(); btnMoreCards = new javax.swing.JLabel(); txt_time_u0 = new javax.swing.JLabel(); jPanel12 = new javax.swing.JPanel(); jPanel21 = new javax.swing.JPanel(); jPanel22 = new javax.swing.JPanel(); jPanel14 = new javax.swing.JPanel(); icon_u3 = new javax.swing.JLabel(); active_u3 = new javax.swing.JLabel(); card_u3_c0 = new javax.swing.JLabel(); card_u3_c1 = new javax.swing.JLabel(); card_u3_c2 = new javax.swing.JLabel(); card_u3_c3 = new javax.swing.JLabel(); card_u3_c4 = new javax.swing.JLabel(); card_u3_c5 = new javax.swing.JLabel(); card_u3_c6 = new javax.swing.JLabel(); card_u3_start = new javax.swing.JLabel(); txt_time_u3 = new javax.swing.JLabel(); jPanel23 = new javax.swing.JPanel(); btnStart = new javax.swing.JButton(); setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS)); jPanel3.setBackground(new java.awt.Color(255, 51, 51)); jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); jPanel18.setBackground(new java.awt.Color(204, 255, 255)); javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18); jPanel18.setLayout(jPanel18Layout); jPanel18Layout.setHorizontalGroup( jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 390, Short.MAX_VALUE) ); jPanel18Layout.setVerticalGroup( jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 206, Short.MAX_VALUE) ); jPanel3.add(jPanel18); jPanel19.setBackground(new java.awt.Color(204, 255, 255)); jPanel13.setMaximumSize(new java.awt.Dimension(380, 200)); jPanel13.setMinimumSize(new java.awt.Dimension(380, 200)); jPanel13.setOpaque(false); jPanel13.setPreferredSize(new java.awt.Dimension(380, 200)); jPanel13.setRequestFocusEnabled(false); jPanel13.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); icon_u1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); icon_u1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/user/user_3.png"))); // NOI18N jPanel13.add(icon_u1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 25, 70, 60)); active_u1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); active_u1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FundoUser.png"))); // NOI18N jPanel13.add(active_u1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 20, -1, -1)); card_u1_c0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c0, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, -1, 80)); card_u1_c1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 120, -1, 80)); card_u1_c2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c2, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 120, -1, 80)); card_u1_c3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c3, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 120, -1, 80)); card_u1_c4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c4, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 120, -1, 80)); card_u1_c5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c5, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 120, -1, 80)); card_u1_c6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u1_c6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_c6, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 120, -1, 80)); card_u1_start.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel13.add(card_u1_start, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 20, -1, 80)); txt_time_u1.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N txt_time_u1.setForeground(new java.awt.Color(255, 51, 51)); txt_time_u1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txt_time_u1.setText("00:05"); jPanel13.add(txt_time_u1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 90, 70, 20)); jPanel19.add(jPanel13); jPanel3.add(jPanel19); jPanel20.setBackground(new java.awt.Color(204, 255, 255)); btnOut.setText("Voltar"); btnOut.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnOutActionPerformed(evt); } }); javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20); jPanel20.setLayout(jPanel20Layout); jPanel20Layout.setHorizontalGroup( jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel20Layout.createSequentialGroup() .addComponent(btnOut, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 229, Short.MAX_VALUE)) ); jPanel20Layout.setVerticalGroup( jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel20Layout.createSequentialGroup() .addContainerGap(188, Short.MAX_VALUE) .addComponent(btnOut) .addGap(14, 14, 14)) ); jPanel3.add(jPanel20); add(jPanel3); jPanel6.setBackground(new java.awt.Color(51, 51, 255)); jPanel6.setLayout(new javax.swing.BoxLayout(jPanel6, javax.swing.BoxLayout.Y_AXIS)); jPanel9.setBackground(new java.awt.Color(204, 255, 255)); jPanel10.setMaximumSize(new java.awt.Dimension(380, 200)); jPanel10.setMinimumSize(new java.awt.Dimension(380, 200)); jPanel10.setOpaque(false); jPanel10.setPreferredSize(new java.awt.Dimension(380, 200)); jPanel10.setRequestFocusEnabled(false); jPanel10.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); icon_u2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); icon_u2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/user/user_3.png"))); // NOI18N jPanel10.add(icon_u2, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 10, 70, 60)); active_u2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); active_u2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FundoUser.png"))); // NOI18N jPanel10.add(active_u2, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 5, -1, -1)); card_u2_c0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c0, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, -1, 80)); card_u2_c1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 120, -1, 80)); card_u2_c2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c2, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 120, -1, 80)); card_u2_c3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c3, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 120, -1, 80)); card_u2_c4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c4, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 120, -1, 80)); card_u2_c5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c5, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 120, -1, 80)); card_u2_c6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u2_c6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_c6, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 120, -1, 80)); card_u2_start.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel10.add(card_u2_start, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 20, -1, 80)); txt_time_u2.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N txt_time_u2.setForeground(new java.awt.Color(255, 51, 51)); txt_time_u2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txt_time_u2.setText("00:05"); jPanel10.add(txt_time_u2, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 80, 70, 20)); jPanel9.add(jPanel10); jPanel6.add(jPanel9); panel.setBackground(new java.awt.Color(204, 255, 255)); panelTable.setMaximumSize(new java.awt.Dimension(300, 200)); panelTable.setMinimumSize(new java.awt.Dimension(300, 200)); panelTable.setOpaque(false); panelTable.setPreferredSize(new java.awt.Dimension(300, 200)); panelTable.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N panelTable.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 40, -1, 80)); jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N panelTable.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 50, 50, 80)); discard_1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N panelTable.add(discard_1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, -1, 80)); discard_2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N panelTable.add(discard_2, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 60, -1, 80)); discard_3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N panelTable.add(discard_3, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 40, -1, 80)); jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N panelTable.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 50, -1, 80)); panel.add(panelTable); jPanel6.add(panel); jPanel5.setBackground(new java.awt.Color(204, 255, 255)); jPanel11.setMaximumSize(new java.awt.Dimension(380, 200)); jPanel11.setMinimumSize(new java.awt.Dimension(380, 200)); jPanel11.setOpaque(false); jPanel11.setPreferredSize(new java.awt.Dimension(380, 200)); jPanel11.setRequestFocusEnabled(false); jPanel11.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); icon_u0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); icon_u0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/user/user_3.png"))); // NOI18N jPanel11.add(icon_u0, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 5, 70, 60)); active_u0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); active_u0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FundoUser.png"))); // NOI18N jPanel11.add(active_u0, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 0, -1, -1)); card_u0_c0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c0, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, 80)); card_u0_c1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c1, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 40, -1, 80)); card_u0_c2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, -1, 80)); card_u0_c3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c3, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 120, -1, 80)); card_u0_c4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c4, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 120, -1, 80)); card_u0_c5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c5, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 120, -1, 80)); card_u0_c6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u0_c6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_c6, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 120, -1, 80)); card_u0_start.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel11.add(card_u0_start, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 0, -1, 80)); btnMoreCards.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/more_cards.png"))); // NOI18N jPanel11.add(btnMoreCards, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 140, -1, -1)); txt_time_u0.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N txt_time_u0.setForeground(new java.awt.Color(255, 51, 51)); txt_time_u0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txt_time_u0.setText("00:05"); jPanel11.add(txt_time_u0, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 70, 70, 20)); jPanel5.add(jPanel11); jPanel6.add(jPanel5); add(jPanel6); jPanel12.setBackground(new java.awt.Color(255, 51, 51)); jPanel12.setLayout(new javax.swing.BoxLayout(jPanel12, javax.swing.BoxLayout.Y_AXIS)); jPanel21.setBackground(new java.awt.Color(204, 255, 255)); javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21); jPanel21.setLayout(jPanel21Layout); jPanel21Layout.setHorizontalGroup( jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 390, Short.MAX_VALUE) ); jPanel21Layout.setVerticalGroup( jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 197, Short.MAX_VALUE) ); jPanel12.add(jPanel21); jPanel22.setBackground(new java.awt.Color(204, 255, 255)); jPanel14.setMaximumSize(new java.awt.Dimension(380, 200)); jPanel14.setMinimumSize(new java.awt.Dimension(380, 200)); jPanel14.setOpaque(false); jPanel14.setPreferredSize(new java.awt.Dimension(380, 200)); jPanel14.setRequestFocusEnabled(false); jPanel14.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); icon_u3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); icon_u3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/user/user_3.png"))); // NOI18N jPanel14.add(icon_u3, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 25, 70, 60)); active_u3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); active_u3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FundoUser.png"))); // NOI18N jPanel14.add(active_u3, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 20, -1, -1)); card_u3_c0.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c0, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, -1, 80)); card_u3_c1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 120, -1, 80)); card_u3_c2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c2, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 120, -1, 80)); card_u3_c3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c3, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 120, -1, 80)); card_u3_c4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c4, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 120, -1, 80)); card_u3_c5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c5, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 120, -1, 80)); card_u3_c6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); card_u3_c6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_c6, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 120, -1, 80)); card_u3_start.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cartas/costas.png"))); // NOI18N jPanel14.add(card_u3_start, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 20, -1, 80)); txt_time_u3.setFont(new java.awt.Font("Arial Black", 1, 14)); // NOI18N txt_time_u3.setForeground(new java.awt.Color(255, 51, 51)); txt_time_u3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); txt_time_u3.setText("00:05"); jPanel14.add(txt_time_u3, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 90, 70, 20)); jPanel22.add(jPanel14); jPanel12.add(jPanel22); jPanel23.setBackground(new java.awt.Color(204, 255, 255)); btnStart.setText("Iniciar"); btnStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnStartActionPerformed(evt); } }); javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23); jPanel23.setLayout(jPanel23Layout); jPanel23Layout.setHorizontalGroup( jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel23Layout.createSequentialGroup() .addComponent(btnStart, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 229, Short.MAX_VALUE)) ); jPanel23Layout.setVerticalGroup( jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup() .addContainerGap(197, Short.MAX_VALUE) .addComponent(btnStart) .addGap(14, 14, 14)) ); jPanel12.add(jPanel23); add(jPanel12); }// </editor-fold>//GEN-END:initComponents private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed // TODO add your handling code here: controller.onBtnStartClicked(); btnStart.setVisible(false); }//GEN-LAST:event_btnStartActionPerformed private void btnOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOutActionPerformed // TODO add your handling code here: controller.returnPage(); }//GEN-LAST:event_btnOutActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel active_u0; private javax.swing.JLabel active_u1; private javax.swing.JLabel active_u2; private javax.swing.JLabel active_u3; private javax.swing.JLabel btnMoreCards; private javax.swing.JButton btnOut; private javax.swing.JButton btnStart; private javax.swing.JLabel card_u0_c0; private javax.swing.JLabel card_u0_c1; private javax.swing.JLabel card_u0_c2; private javax.swing.JLabel card_u0_c3; private javax.swing.JLabel card_u0_c4; private javax.swing.JLabel card_u0_c5; private javax.swing.JLabel card_u0_c6; private javax.swing.JLabel card_u0_start; private javax.swing.JLabel card_u1_c0; private javax.swing.JLabel card_u1_c1; private javax.swing.JLabel card_u1_c2; private javax.swing.JLabel card_u1_c3; private javax.swing.JLabel card_u1_c4; private javax.swing.JLabel card_u1_c5; private javax.swing.JLabel card_u1_c6; private javax.swing.JLabel card_u1_start; private javax.swing.JLabel card_u2_c0; private javax.swing.JLabel card_u2_c1; private javax.swing.JLabel card_u2_c2; private javax.swing.JLabel card_u2_c3; private javax.swing.JLabel card_u2_c4; private javax.swing.JLabel card_u2_c5; private javax.swing.JLabel card_u2_c6; private javax.swing.JLabel card_u2_start; private javax.swing.JLabel card_u3_c0; private javax.swing.JLabel card_u3_c1; private javax.swing.JLabel card_u3_c2; private javax.swing.JLabel card_u3_c3; private javax.swing.JLabel card_u3_c4; private javax.swing.JLabel card_u3_c5; private javax.swing.JLabel card_u3_c6; private javax.swing.JLabel card_u3_start; private javax.swing.JLabel discard_1; private javax.swing.JLabel discard_2; private javax.swing.JLabel discard_3; private javax.swing.JLabel icon_u0; private javax.swing.JLabel icon_u1; private javax.swing.JLabel icon_u2; private javax.swing.JLabel icon_u3; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel10; private javax.swing.JPanel jPanel11; private javax.swing.JPanel jPanel12; private javax.swing.JPanel jPanel13; private javax.swing.JPanel jPanel14; private javax.swing.JPanel jPanel18; private javax.swing.JPanel jPanel19; private javax.swing.JPanel jPanel20; private javax.swing.JPanel jPanel21; private javax.swing.JPanel jPanel22; private javax.swing.JPanel jPanel23; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel9; private javax.swing.JPanel panel; private javax.swing.JPanel panelTable; private javax.swing.JLabel txt_time_u0; private javax.swing.JLabel txt_time_u1; private javax.swing.JLabel txt_time_u2; private javax.swing.JLabel txt_time_u3; // End of variables declaration//GEN-END:variables private void disableLabel() { card_u0_c0.setVisible(false); card_u0_c1.setVisible(false); card_u0_c2.setVisible(false); card_u0_c3.setVisible(false); card_u0_c4.setVisible(false); card_u0_c5.setVisible(false); card_u0_c6.setVisible(false); card_u1_c0.setVisible(false); card_u1_c1.setVisible(false); card_u1_c2.setVisible(false); card_u1_c3.setVisible(false); card_u1_c4.setVisible(false); card_u1_c5.setVisible(false); card_u1_c6.setVisible(false); card_u2_c0.setVisible(false); card_u2_c1.setVisible(false); card_u2_c2.setVisible(false); card_u2_c3.setVisible(false); card_u2_c4.setVisible(false); card_u2_c5.setVisible(false); card_u2_c6.setVisible(false); card_u3_c0.setVisible(false); card_u3_c1.setVisible(false); card_u3_c2.setVisible(false); card_u3_c3.setVisible(false); card_u3_c4.setVisible(false); card_u3_c5.setVisible(false); card_u3_c6.setVisible(false); card_u0_start.setVisible(false); card_u1_start.setVisible(false); card_u2_start.setVisible(false); card_u3_start.setVisible(false); active_u0.setVisible(false); active_u1.setVisible(false); active_u2.setVisible(false); active_u3.setVisible(false); btnStart.setVisible(false); btnMoreCards.setEnabled(false); txt_time_u0.setVisible(false); txt_time_u1.setVisible(false); txt_time_u2.setVisible(false); txt_time_u3.setVisible(false); } public void showStartButton() { btnStart.setVisible(true); } void setStartCardVisible(boolean b) { card_u0_start.setVisible(b); card_u1_start.setVisible(b); card_u2_start.setVisible(b); card_u3_start.setVisible(b); } void setStackPlayedVisible(boolean b){ discard_1.setVisible(b); discard_2.setVisible(b); discard_3.setVisible(b); } void updateTimeForUser(int playerIndex, int time) { timeUserLabel[playerIndex].setText("00:0"+time); } void setTimePlayerVisible(int playerIndex, boolean b) { timeUserLabel[playerIndex].setVisible(b); } }
package com.bmo.student; import java.util.Scanner; public class StudentRunner { public static void main(String[] args) { // userInput(); com.bmo.kotlin.Student.getPass(); Student.pass = 40; Student stu = new Student("Bmo", 77, 60); Student stu2 = new Student("Tom", 50, 40); Student stu3= new Student("AJi", 30, 55); stu.print(); stu2.print(); stu3.print(); System.out.println("High score: " + stu.highest()); } private static void userInput() { Scanner scanner = new Scanner(System.in); System.out.println("Please enter student's name:"); String name = scanner.next(); System.out.println("Please enter student's english:"); int english = scanner.nextInt(); System.out.println("Please enter student's math:"); int math = scanner.nextInt(); } }
/** * PromotionsDAO.java $version 2018. 7. 30. * * Copyright 2018 NAVER Corp. All rights Reserved. * NAVER PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package com.nts.pjt3.dao; import java.util.List; import org.springframework.stereotype.Repository; import com.nts.pjt3.dto.Promotion; /** * @author Seok Jeongeum * */ @Repository public interface PromotionDao { /** * @author Created by Seok Jeongeum on 2018. 8. 9. */ public List<Promotion> selectAll(); /** * @author Created by Seok Jeongeum on 2018. 8. 9. */ public Integer selectCount(); }
/** * */ package com.controller; import com.model.AddressBook; import com.model.Person; import com.serviceImplementation.AddressBookService; import com.serviceImplementation.DBService; import com.serviceImplementation.PersonService; import com.serviceInterface.Service; import java.util.ArrayList; import java.util.Scanner; /** * @author bridgelabz * */ /* * Work with switch cases, because let's face it , you cannot make GUI so fast! * Supposably "controller" is suppose to just move and control, * But we all know who controls you! * Make GUI Fast before you forget ! */ public class AddressBookController { public static void main(String args[])throws Exception { Scanner sc = new Scanner( System.in ); System.out.println( "Welcome ! I am the Controller Here ! \n" + " I can-troll everything " ); System.out.println( "I shall give you options, Choose Wisely !" ); System.out.println( "How many AddressBooks are we talking about here ? " ); int numberOfAddressBooks = sc.nextInt(); sc.nextLine(); System.out.println( "Okay , I can controll " + numberOfAddressBooks + " Address Book(s). "); ArrayList<AddressBook> listOfAddressBooks = new ArrayList<AddressBook>(); for( int booksAccesed = 0 ; booksAccesed < numberOfAddressBooks ; booksAccesed ++ ){ String choice = null; do { System.out.println( "Now Now \n" + "Enter 1 to Load Address Book from file system, 2 to Create New Address Book , 3 to Load Address Book from DB!"); choice = sc.nextLine(); }while(!choice.equalsIgnoreCase("1") && !choice.equalsIgnoreCase("2") && !choice.equalsIgnoreCase("3")); if(choice.equalsIgnoreCase("1")){ AddressBook elementBook = new AddressBook(); Service newBookService = new AddressBookService(); newBookService.fillAddressBookFromJSON(elementBook); System.out.println( "Enter Address Book ID you want to give!" ); String id = sc.nextLine(); elementBook.setId(id); listOfAddressBooks.add(elementBook); } if( choice.equalsIgnoreCase("2") ){ AddressBook elementBook = new AddressBook(); System.out.println( "Enter Address Book ID you want to give!" ); String id = sc.nextLine(); elementBook.setId(id); Service newBookService = new AddressBookService(); newBookService.fillAddressBookDetails( elementBook ); listOfAddressBooks.add(elementBook); } if(choice.equalsIgnoreCase("3")){ DBService.workWithDBForAddressBook(); } } System.out.println( "Now that everything has been initialized , it's time to take con-troll !" ); String choice = ""; do{ System.out.println( "Enter 1 to work with AddressBook , 0 to Exit!" ); choice = sc.nextLine(); if(choice.equalsIgnoreCase("1")){ System.out.println( "Enter address book id !" ); String id = sc.nextLine(); Service newBookService = new AddressBookService(); Service newPersonService = new PersonService(); AddressBook currentBook = newBookService.searchAddressBook( listOfAddressBooks , id ); if(currentBook != null ){ String option = null; do { System.out.println( "Enter 1 to Show Details of AddressBook , 2 to Add Person to AddressBook , 3 to Delete a Person ( Forever ) , 4 to Edit information of a Person " ); System.out.println( " 5 to Sort Entries by ZipCode , 6 to Sort Entries by Name (Last and then First) , 7 to Write AddressBook to File in JSON Format " ); System.out.println( "8 To show details of a Person , 0 To Exit this ( Matrix Neil ) " ); option = sc.nextLine(); if(option.equalsIgnoreCase("1")){ newBookService.showAddressBookDetails( currentBook ); } else if ( option.equalsIgnoreCase("2") ) { newBookService.addPerson( currentBook ); } else if ( option.equalsIgnoreCase("3") ) { newBookService.deletePerson( currentBook ); } else if( option.equalsIgnoreCase("4" ) ){ newPersonService.editPersonalDetails( currentBook ); } else if ( option.equalsIgnoreCase("5") ){ newBookService.sortByZipCode( currentBook ); } else if ( option.equalsIgnoreCase( "6") ){ newBookService.sortByName( currentBook ); } else if ( option.equalsIgnoreCase("7") ){ newBookService.writeToJSONFromAddressBook( currentBook ); } else if ( option.equalsIgnoreCase("8") ){ System.out.println( "Enter firstName followed by lastName" ); String firstName = sc.nextLine(); String lastName = sc.nextLine(); Person individual = newBookService.searchPerson( currentBook, firstName, lastName ); newPersonService.showPersonalDetails( individual ); } else if( option.equalsIgnoreCase("0") ){ continue; } else{ System.out.println( "Invalid Option!!" ); } }while ( !option.equalsIgnoreCase("0") ); } else{ System.out.println( "No such AddressBook found with id :" + id ); continue; } } else if( choice.equalsIgnoreCase("0") ){ continue; } else{ System.out.println( "Enter a valid choice!!" ); } }while(!choice.equalsIgnoreCase("0")); sc.close(); } }
package com.tencent.mm.plugin.wallet_payu.bind.ui; import android.text.Editable; import com.tencent.mm.plugin.wallet_payu.bind.ui.WalletPayUCardElementUI.a; class WalletPayUCardElementUI$1 extends a { final /* synthetic */ WalletPayUCardElementUI pEt; WalletPayUCardElementUI$1(WalletPayUCardElementUI walletPayUCardElementUI) { this.pEt = walletPayUCardElementUI; super(walletPayUCardElementUI, (byte) 0); } public final void afterTextChanged(Editable editable) { WalletPayUCardElementUI.a(this.pEt, WalletPayUCardElementUI.a(this.pEt), editable); } }
package magical.robot.ioio; import java.util.Timer; import java.util.TimerTask; import magical.robot.main.NanExeption; import ioio.lib.api.AnalogInput; import ioio.lib.api.IOIO; import ioio.lib.api.exception.ConnectionLostException; /** * this class handles all functionality of the robot's movement * @author гешеп */ public class MovmentSystem implements Stoppable{ private ChassisFrame _chassis; private RoboticArmEdge _arm; private AnalogInput _wristPosition; private AnalogInput _sholderPosition; private AnalogInput _elbowPosition; private AnalogInput _distance; private Timer _stopTimer = new Timer("Stop Timer"); private static final float y1 = 75; private static final float x2 = (float) 0.607; private static final float diferential = -y1/x2; public static final int ELBOW_FIRST = 0; public static final int SHOLDER_FIRST = 1; public MovmentSystem(IOIO ioio, ChassisFrame chassis, RoboticArmEdge arm, int wristPositionPin, int sholderPositionPin, int elbowPositionPin, int distancePin) { _chassis = chassis; _arm = arm; try { _wristPosition = ioio.openAnalogInput(wristPositionPin); _sholderPosition = ioio.openAnalogInput(sholderPositionPin); _elbowPosition = ioio.openAnalogInput(elbowPositionPin); _distance = ioio.openAnalogInput(distancePin); } catch (ConnectionLostException e) { e.printStackTrace(); } } /** * simple getter * @return */ public RoboticArmEdge get_arm() { return _arm; } /** * simple getter * @return */ public ChassisFrame get_chassis() { return _chassis; } /** * gets the elbow position by the potentiometer on the arm * @return the elbow position * @throws InterruptedException * @throws ConnectionLostException */ public float get_elbowPosition() throws InterruptedException, ConnectionLostException { return _elbowPosition.read(); } /** * gets the shoulder position by the potentiometer on the arm * @return the shoulder position * @throws InterruptedException * @throws ConnectionLostException */ public float get_sholderPosition() throws InterruptedException, ConnectionLostException { return _sholderPosition.read(); } /** * gets the wrist position by the potentiometer on the arm * @return the wrist position * @throws InterruptedException * @throws ConnectionLostException */ public float get_wristPosition() throws InterruptedException, ConnectionLostException { return _wristPosition.read(); } /** * gets the distance given by the distance sensor on the front of the robot * @return returns the distance from the object in front of the rover * @throws InterruptedException * @throws ConnectionLostException */ public float get_distance() throws InterruptedException, ConnectionLostException { return _distance.read(); } /** * closes all relevant digital pins */ public void close() { _elbowPosition.close(); _sholderPosition.close(); _sholderPosition.close(); _distance.close(); _chassis.close(); _arm.close(); } /** * move the shoulder in a certain degree * @param degree the degree to move the arm, the sign of degree will determine the direction * @throws ConnectionLostException * @throws InterruptedException */ public void moveSholder(double degree) throws ConnectionLostException, InterruptedException{ if (degree > 90){ degree = 90; } double PositionToGet = (degree * RobotSettings.sholderMov) + 0.64786904; float sholderPosition = get_sholderPosition(); if (sholderPosition > PositionToGet){ _arm.sholderDown(); while(get_sholderPosition() > PositionToGet){ Thread.sleep(10); } } else if (sholderPosition < PositionToGet){ _arm.sholderUp(); while (get_sholderPosition() < PositionToGet){ Thread.sleep(10); } } _arm.stop(); } /** * move the elbow in a certain degree * @param degree the degree to move the arm, the sign of degree will determine the direction * @throws ConnectionLostException * @throws InterruptedException */ public void moveElbow(double degree) throws ConnectionLostException, InterruptedException { if(degree > 90){ degree = 90; } double PositionToGet = 0.7311828 - (degree * RobotSettings.elbowMov); float elbowPosition = get_elbowPosition(); if (elbowPosition < PositionToGet){ _arm.elbowDown(); while(get_elbowPosition() < PositionToGet){ Thread.sleep(10); } } else if (elbowPosition > PositionToGet){ _arm.elbowUp(); while(get_elbowPosition() > PositionToGet){ Thread.sleep(10); } } _arm.stop(); } /** * this function lowers the arm to grab the cube infront of the rover * @param distance rover distance from the cube * @throws ConnectionLostException * @throws InterruptedException * @throws NanExeption */ public void moveArm(double distance) throws ConnectionLostException, InterruptedException, NanExeption{ moveArmToPutCube(distance, 1, SHOLDER_FIRST); } /** * this function moves the arm to the position on the tower * @param distance from the cube layed in-front of the rover * @param amountOfCube the number of cube in the tower * @throws ConnectionLostException * @throws InterruptedException * @throws NanExeption */ public void moveArmToPutCube(double distance, int amountOfCube, int order) throws ConnectionLostException, InterruptedException, NanExeption{ double[] cube = new double [2]; // cube vertical position cube[0] = 0; // cube height cube[1] = RobotSettings.cubeSize * amountOfCube + RobotSettings.cubeSize/2 + 1.5; // fixing the first joint distance from cube, the sensor is closer to the cube distance += 3; //height to the base of the arm's first joint double[] D1_base = {distance, 17}; //length from shoulder to elbow double d1 = 9; //length from elbow to wrist double d2 = 11; //length from wrist to hand double d3 = 7; double a3 = ((55) * Math.PI) / 180; double[] D0 = D1_base; double[] D3 = cube; double b3 = Math.sqrt(d2*d2 + d3*d3 - 2 * d2 * d3 * Math.cos(Math.PI - a3)); double[] xx = new double [2]; xx[0] = D0[0] - D3[0]; xx[1] = D0[1] - D3[1]; double b0 = Math.sqrt(xx[0]*xx[0] + xx[1]*xx[1]); if(b0 > d1 + b3){ //this.moveForward(b0 - (d1 + b3) + 3); //this.moveArm(distance - (b0 - (d1 + b3) + 3)); return; } double beta0 = Math.acos((b0*b0 - d1*d1 - b3*b3) / (-2*d1*b3)); if (Double.isNaN(beta0)) throw new NanExeption("beta0 - acos"); //System.out.println(beta0); double gamma3 = Math.asin((d3/b3) * Math.sin(Math.PI - a3)); if (Double.isNaN(gamma3)) throw new NanExeption("gamma3 - asin"); double a2 = Math.PI - beta0 - gamma3; double beta3 = Math.asin((b3/b0) * Math.sin(beta0)); if (Double.isNaN(beta3)) throw new NanExeption("beta3 - asin"); double betax = Math.atan(xx[0] / xx[1]); double a1 = Math.PI - betax - beta3; double a1_degrees = a1 * (180 / Math.PI); double a2_degrees = a2 * (180 / Math.PI); if (Double.isNaN(90-a1_degrees) || Double.isNaN(90-a2_degrees)){ System.out.println(b3 / ( b0*Math.sin(beta0))); System.out.println(a1); System.out.println(betax); System.out.println(beta3); System.out.println(D3[0]); System.exit(0); } if (order == SHOLDER_FIRST){ this.moveSholder(90 - a1_degrees); this.moveElbow(90 - a2_degrees); } else if (order == ELBOW_FIRST){ this.moveElbow(90 - a2_degrees); this.moveSholder(90 - a1_degrees); } System.out.println("sholder need to move:" + (90 - a1_degrees)); System.out.println("elbow need to move:" + (90 - a2_degrees)); } public void bring_to_fix_place() throws InterruptedException, ConnectionLostException{ double PositionToGet = 0.5464321; float elbowPosition = get_elbowPosition(); if (elbowPosition < PositionToGet){ _arm.elbowDown(); while(get_elbowPosition() < PositionToGet){ Thread.sleep(10); } } else if (elbowPosition > PositionToGet){ _arm.elbowUp(); while(get_elbowPosition() > PositionToGet){ Thread.sleep(10); } } _arm.stop(); PositionToGet = 0.629521; float sholderPosition= get_sholderPosition(); if (sholderPosition > PositionToGet){ _arm.sholderDown(); while(get_sholderPosition() > PositionToGet){ Thread.sleep(10); } } else if (sholderPosition < PositionToGet){ _arm.sholderUp(); while (get_sholderPosition() < PositionToGet){ Thread.sleep(10); } } _arm.stop(); } /** * turn around in place * @param dgree a degree to be turned * @throws ConnectionLostException */ public void turnAround(double dgree) throws ConnectionLostException{ long driveTime = (long) (RobotSettings.turnaroundTime * Math.abs(dgree)); if (dgree < 0){ _chassis.turnLeft(); } else { _chassis.turnRight(); } System.out.println(driveTime); _stopTimer.schedule(new StopMovment(_chassis), driveTime * 1000); } public void turnRight() throws ConnectionLostException{ _chassis.turnRight(); } public void turnLeft() throws ConnectionLostException{ _chassis.turnLeft(); } /** * moves the robot forwards x centimeters * @param centimeters centimeters to move * @throws ConnectionLostException */ public void moveForward(double centimeters) throws ConnectionLostException{ long driveTime = (long) (RobotSettings.movmentSpeed / centimeters * 1000); _chassis.driveForward(); _stopTimer.schedule(new StopMovment(_chassis), driveTime); } /** * moves the robot forward (without stopping) * @throws ConnectionLostException */ public void moveForwardCont() throws ConnectionLostException{ _chassis.driveForward(); } /** * command the hand to grab a cube * @throws ConnectionLostException */ public void grabCube() throws ConnectionLostException{ long driveTime =(long) (RobotSettings.clawTime * 1000); _arm.closeHand(); _stopTimer.schedule(new StopMovment(_arm._wrist_and_grasp), driveTime); } /** * open the arm to release a cube * @throws ConnectionLostException */ public void releaseCube() throws ConnectionLostException{ long driveTime =(long) (RobotSettings.clawTime * 1000); _arm.openHand(); _stopTimer.schedule(new StopMovment(_arm._wrist_and_grasp), driveTime); } /** * moves the robot backwards x centimeters * @param centimeters centimeters to move * @throws ConnectionLostException */ public void moveBackwards(double centimeters) throws ConnectionLostException{ long driveTime = (long) (RobotSettings.movmentSpeed / centimeters * 1000); _chassis.driveBackwards(); _stopTimer.schedule(new StopMovment(_chassis), driveTime); } public void driveBackwardsCont() throws ConnectionLostException{ _chassis.driveBackwards(); } @Override public void stop() throws ConnectionLostException { _arm.stop(); _chassis.stop(); } /** * sets the drive speed of the rover * @param speed the new speed value * @throws ConnectionLostException */ public void setRoverSpeed(float speed) throws ConnectionLostException { _chassis.setSpeed(speed); } /** * this classes implements the TimerTask abstract class * the goal of this class is to stop a certain stoppable object * @author гешеп * */ public class StopMovment extends TimerTask{ private Stoppable _obj; /** * @param obj an object to be stopped */ public StopMovment(Stoppable obj) { _obj = obj; } @Override public void run() { try { System.out.println("stoping..."); _obj.stop(); } catch (ConnectionLostException e) { // TODO Auto-generated catch block e.printStackTrace(); } }// run() }// StopMovment /** * this function brings up the arm to a certain position after grabbing a cube * @throws ConnectionLostException * @throws InterruptedException */ public void bringArmUp() throws ConnectionLostException, InterruptedException { this.moveSholder(45); this.moveElbow(45); } /** * picks up a cube, releases it and brings back up the arm * @throws InterruptedException * @throws ConnectionLostException * @throws NanExeption */ public void takeCube() throws ConnectionLostException, InterruptedException, NanExeption{ //this.moveArm(15/*this.getDistanceCentimeters()*/); this.moveArmToPutCube(13, 1, this.SHOLDER_FIRST); //bring_to_fix_place(); this.grabCube(); Thread.sleep((long)(RobotSettings.clawTime * 1000)); this.bringArmUp(); } /** * this function places a cube in a certain level. * pre-assumeing that the cube is held by the robot * @param level the level of the cube to be put at, for example - cube 3 == level 3 * @throws ConnectionLostException * @throws InterruptedException * @throws NanExeption */ public void placeCube(int level) throws ConnectionLostException, InterruptedException, NanExeption{ this.moveArmToPutCube(13, 2, SHOLDER_FIRST); this.releaseCube(); Thread.sleep((long)(RobotSettings.clawTime * 1000)); this.bringArmUp(); } /** * gets the distance in centimeters from the first object in-front of the rover * @return the distance from an object in-front of the rover * @throws ConnectionLostException * @throws InterruptedException */ public float getDistanceCentimeters() throws InterruptedException, ConnectionLostException{ return (float) 34.667 - (float)38.61 * this.get_distance(); } public void moveArm(int sholder, int elbow) throws ConnectionLostException, InterruptedException { this.moveSholder(sholder); this.moveElbow(elbow); } public void initArm() throws ConnectionLostException, InterruptedException{ this.releaseCube(); bringArmUp(); } }
package design.mode.factory.FactoryMethod; import design.mode.factory.Milk; public interface MilkFactory { public Milk getMilk(); }
package com.ibm.ive.tools.japt.reduction.rta; import com.ibm.ive.tools.japt.reduction.ClassSet; import com.ibm.ive.tools.japt.reduction.xta.Field; import com.ibm.ive.tools.japt.reduction.xta.MethodPropagator; import com.ibm.ive.tools.japt.reduction.xta.Repository; import com.ibm.jikesbt.BT_Field; import com.ibm.jikesbt.BT_HashedClassVector; /** * @author sfoley * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ public class RTAField extends Field { /** * Constructor for RTAField. * @param repository * @param field */ public RTAField(Repository repository, BT_Field field, BT_HashedClassVector propagatedObjects, ClassSet allPropagatedObjects) { super(repository, field, propagatedObjects, allPropagatedObjects); } /** * In RTA we are not interested in the propagation of objects on a local scale, * so this method overrides its parent and does nothing */ protected void addReadingMethod(MethodPropagator accessor) {} /** * we are not interested in propagating objects since we cannot find new targets or create new objects. */ protected void propagateObjects() {} /** * repropagation is not necessary for RTA fields since they have no targets */ protected boolean requiresRepropagation() { return false; } }
package it.dstech.film.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import it.dstech.film.model.Film; @Service("filmService") @Transactional public class FilmServiceImpl implements FilmService { @Autowired FilmService dao; public List<Film> findAllFilms() { return dao.findAllFilms(); } public Film findById(int id) { return dao.findById(id); } public Film findByAttore(String nome) { return dao.findByAttore(nome); } public Film findByRegista(String nome) { return dao.findByRegista(nome); } public Film findByGenere(String nome) { return dao.findByGenere(nome); } public void save(Film film) { dao.save(film); } public void deleteById(int id) { dao.deleteById(id); } public void update(Film film) { dao.update(film); } public Film findByTitolo(String titolo) { return dao.findByTitolo(titolo); } }
package com.tt.frontendapiinterface; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import com.tt.miniapphost.AppBrandLogger; import com.tt.miniapphost.util.DebugUtil; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; public class ApiCallResult implements Parcelable { public static final Parcelable.Creator<ApiCallResult> CREATOR = new Parcelable.Creator<ApiCallResult>() { }; public final JSONObject a; private final String b; protected ApiCallResult(Parcel paramParcel) { JSONObject jSONObject; String str2 = paramParcel.readString(); String str1 = str2; if (str2 == null) { DebugUtil.outputError("ApiCallResult", new Object[] { "读取到空的 Api 执行结果" }); str1 = ""; } try { jSONObject = new JSONObject(str1); } catch (JSONException jSONException) { jSONObject = new JSONObject(); DebugUtil.outputError("ApiCallResult", new Object[] { "从执行结果解析为 JsonObject 时异常 result:", str1, jSONException }); } this.b = str1; this.a = jSONObject; } private ApiCallResult(JSONObject paramJSONObject, boolean paramBoolean) { this.a = paramJSONObject; this.b = this.a.toString(); } public int describeContents() { return 0; } public String toString() { return this.b; } public void writeToParcel(Parcel paramParcel, int paramInt) { paramParcel.writeString(this.b); } public static final class a { private final boolean a; private final String b; private final String c; private String d; private JSONObject e; private int f; public a(String param1String1, String param1String2) { boolean bool; this.b = param1String1; this.c = param1String2; if (param1String2 == "fail") { bool = true; } else { bool = false; } this.a = bool; } public static a a(String param1String) { return new a(param1String, "ok"); } public static a a(String param1String1, String param1String2, int param1Int) { a a1 = (new a(param1String1, "fail")).d(param1String2); a1.f = param1Int; return a1; } @Deprecated public static a b(String param1String) { return new a(param1String, "fail"); } public static a c(String param1String) { return new a(param1String, "cancel"); } public final a a(String param1String, Object param1Object) { if (this.e == null) this.e = new JSONObject(); try { this.e.put(param1String, param1Object); return this; } catch (Exception exception) { AppBrandLogger.e("ApiCallResult", new Object[] { "append", exception }); return this; } } public final a a(Throwable param1Throwable) { this.d = a.a(param1Throwable); return this; } public final a a(HashMap<String, Object> param1HashMap) { this.e = a.a(param1HashMap); return this; } public final a a(JSONObject param1JSONObject) { this.e = param1JSONObject; return this; } public final ApiCallResult a() { JSONObject jSONObject = this.e; if (jSONObject == null) jSONObject = new JSONObject(); try { StringBuilder stringBuilder; String str1 = this.b; String str2 = this.c; String str3 = this.d; boolean bool = TextUtils.isEmpty(str3); if (bool) { stringBuilder = new StringBuilder(); stringBuilder.append(str1); stringBuilder.append(":"); stringBuilder.append(str2); str1 = stringBuilder.toString(); } else { StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.append(str1); stringBuilder1.append(":"); stringBuilder1.append(str2); stringBuilder1.append(" "); stringBuilder1.append((String)stringBuilder); str1 = stringBuilder1.toString(); } jSONObject.put("errMsg", str1); if (this.f != 0) jSONObject.put("errCode", this.f); } catch (Exception exception) { AppBrandLogger.e("ApiCallResult", new Object[] { "build", exception }); } return new ApiCallResult(jSONObject, this.a); } public final a d(String param1String) { this.d = param1String; return this; } public final String toString() { AppBrandLogger.e("ApiCallResult", new Object[] { "请避免使用 Builder 的 toString" }); return a().toString(); } } } /* Location: C:\Users\august\Desktop\tik\df_miniapp\classes.jar!\com\tt\frontendapiinterface\ApiCallResult.class * Java compiler version: 6 (50.0) * JD-Core Version: 1.1.3 */
package chapter_1_04_Objects; import java.time.LocalDate; public class LocDate { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub LocalDate ldNow = LocalDate.now(); System.out.println(ldNow); LocalDate ld = LocalDate.of(2017,2,22); System.out.println(ld); LocalDate ldPlus10 = ld.plusDays(10); System.out.println(ldPlus10); } }
package com.base.crm.report.excel; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSON; import com.base.common.util.ExcelMappingsAbstract; import com.base.crm.ad.entity.ADConsume; import com.base.crm.ad.service.ADConsumeService; import com.base.crm.customer.service.CustInfoService; import com.base.crm.procurement.service.ProcurementCostService; import com.base.crm.report.entity.ServerSaleReport; import com.base.crm.serve.wechat.entity.ServeWechat; import com.base.crm.serve.wechat.service.ServeWechatService; import com.base.crm.users.constants.UserContainer; @Component public class ServerSaleMonthReportExcelMappings extends ExcelMappingsAbstract { private final Logger logger = LoggerFactory.getLogger(getClass()); private static String sheetName ="客服销售业绩"; private static List<String> headerList = Arrays.asList( "月份","客服名称","服务号","加粉总数","订购数","订购率","复购人数","复购率" ,"加粉单价","订购广告单价","销售业绩"); public static List<String> columnsMappings = Arrays.asList( "month","name","wechatNumber","custAddSumNum","orderNumber","orderRate","reorderNumber","reorderRate" ,"addCustPrice","orderAdPrice","salePerforman"); public void setExcelMappings(List<ServerSaleReport> data,ServerSaleReport summeryData) { this.data = JSON.parseArray(JSON.toJSONString(data)); this.collectData = JSON.parseObject(JSON.toJSONString(summeryData)); this.setSheetName(sheetName); } @Autowired private ProcurementCostService procurementCostService; @Autowired private ADConsumeService consumeADService; // @Autowired // private CustOrderService custOrderService; // @Autowired // private ServerSalaryService serverSalaryService; @Autowired private ServeWechatService serveWechatService; @Autowired private CustInfoService custInfoService; @Autowired private UserContainer userContainer; // @Autowired // private CommonConstants commonConstants; @Override public List<String> getHeaderList() { return headerList; } @Override public List<String> getColumnsMappings() { return columnsMappings; } private List<ServerSaleReport> reportResult; public List<ServerSaleReport> getReportResult() { return reportResult; } public void setReportResult(List<ServerSaleReport> reportResult) { this.reportResult = reportResult; } public ExcelMappingsAbstract statistics(ServerSaleReport serverSaleReport) { logger.info("开始统计"+sheetName+"报表新 ServerSaleReport ==== "+serverSaleReport); reportResult = new ArrayList<ServerSaleReport>(); List<String> monthList = procurementCostService.queryMonthBy(serverSaleReport.getMonth()); BigDecimal zero = new BigDecimal(0); ServerSaleReport sumReportResult = new ServerSaleReport(); sumReportResult.setMonth("总计"); for(String month : monthList){ List<ADConsume> realConsumeADList = consumeADService.queryRealConsumeAmount(month); ADConsume monthConsume = new ADConsume(); monthConsume.setConsumeAmount(zero); monthConsume.setRealAmount(zero); monthConsume.setConsumeDate(month); ServerSaleReport monthReport = new ServerSaleReport(); monthReport.setMonth("小计"); for(ADConsume consume : realConsumeADList){ monthConsume.setConsumeAmount(monthConsume.getConsumeAmount().add(consume.getConsumeAmount())); monthConsume.setRealAmount(monthConsume.getRealAmount().add(consume.getRealAmount())); Map<String,Object> map = custInfoService.queryAddCustCountBy(month,consume.getConsumeWechatNo(),consume.getServerId()); BigDecimal salePerforman= custInfoService.queryServerSalePerformanBy(month,consume.getConsumeWechatNo(),consume.getServerId()); BigDecimal addSum = new BigDecimal(map.get("num")+""); BigDecimal orderedNum= new BigDecimal(map.get("ordered")+""); BigDecimal reorderedNum = new BigDecimal(map.get("reordered")+""); ServerSaleReport serverSaleReportResult = new ServerSaleReport(); serverSaleReportResult.setMonth(month); serverSaleReportResult.setName(userContainer.get(consume.getServerId())); serverSaleReportResult.setWechatNumber(consume.getConsumeWechatNo()); serverSaleReportResult.setCustAddSumNum(addSum);// 加粉总数 serverSaleReportResult.setOrderNumber(orderedNum); // 订购总数 serverSaleReportResult.setReorderNumber(reorderedNum);// 复购总数 serverSaleReportResult.setAdConsumeSum(consume.getRealAmount()); serverSaleReportResult.setSalePerforman(salePerforman); BigDecimal orderedRate = divide(serverSaleReportResult.getOrderNumber(), serverSaleReportResult.getCustAddSumNum()); serverSaleReportResult.setOrderRate(orderedRate.doubleValue()); BigDecimal reorderedRate = divide(serverSaleReportResult.getReorderNumber(), serverSaleReportResult.getOrderNumber()); serverSaleReportResult.setReorderRate(reorderedRate.doubleValue()); serverSaleReportResult.setAddCustPrice(divide(consume.getRealAmount(),addSum).doubleValue()); serverSaleReportResult.setOrderAdPrice(divide(consume.getRealAmount(),orderedNum).doubleValue()); reportResult.add(serverSaleReportResult); monthReport.setAdConsumeSum(monthReport.getAdConsumeSum().add(consume.getRealAmount())); monthReport.setCustAddSumNum(monthReport.getCustAddSumNum().add(addSum)); monthReport.setOrderNumber(monthReport.getOrderNumber().add(orderedNum)); monthReport.setReorderNumber(monthReport.getReorderNumber().add(reorderedNum)); BigDecimal sumOrderedRate = divide(monthReport.getOrderNumber(), monthReport.getCustAddSumNum()); monthReport.setOrderRate(sumOrderedRate.doubleValue()); BigDecimal sumReorderedRate = divide(monthReport.getReorderNumber(), monthReport.getOrderNumber()); monthReport.setReorderRate(sumReorderedRate.doubleValue()); monthReport.setSalePerforman(monthReport.getSalePerforman().add(salePerforman)); } monthReport.setAddCustPrice(divide(monthReport.getAdConsumeSum(), monthReport.getCustAddSumNum()).doubleValue()); monthReport.setOrderAdPrice(divide(monthReport.getAdConsumeSum(), monthReport.getOrderNumber()).doubleValue()); sumReportResult.setCustAddSumNum(sumReportResult.getCustAddSumNum().add(monthReport.getCustAddSumNum())); sumReportResult.setOrderNumber(sumReportResult.getOrderNumber().add(monthReport.getOrderNumber())); sumReportResult.setReorderNumber(sumReportResult.getReorderNumber().add(monthReport.getReorderNumber())); sumReportResult.setAdConsumeSum(monthReport.getAdConsumeSum().add(sumReportResult.getAdConsumeSum())); BigDecimal orderRate = divide(sumReportResult.getOrderNumber(), sumReportResult.getCustAddSumNum()); sumReportResult.setOrderRate(orderRate.doubleValue()); BigDecimal reorderRate = divide(sumReportResult.getReorderNumber(), sumReportResult.getOrderNumber()); sumReportResult.setReorderRate(reorderRate.doubleValue()); sumReportResult.setSalePerforman(sumReportResult.getSalePerforman().add(monthReport.getSalePerforman())); reportResult.add(monthReport); } sumReportResult.setAddCustPrice(divide(sumReportResult.getAdConsumeSum(), sumReportResult.getCustAddSumNum()).doubleValue()); sumReportResult.setOrderAdPrice(divide(sumReportResult.getAdConsumeSum(), sumReportResult.getOrderNumber()).doubleValue()); reportResult.add(sumReportResult); setExcelMappings(reportResult, sumReportResult); logger.info("结束统计"+sheetName+"报表新 ServerSaleReport ==== "+reportResult); return this; } private BigDecimal divide(BigDecimal first,BigDecimal second){ BigDecimal result = new BigDecimal(0); if(first.doubleValue()>0 && second.doubleValue()>0){ result = first.divide(second,4,BigDecimal.ROUND_HALF_EVEN); } return result; } }
//package Tests.day9.Task1; // //import Tests.AbstractTest; //import day9.Task1.Teacher; //import org.junit.jupiter.api.Test; // //import static org.junit.jupiter.api.Assertions.assertEquals; // //class Day9TeacherTest extends AbstractTest { // // Teacher teacher = new Teacher("anna", "math"); // // @Test // void printInfo() { // Teacher teacher = new Teacher("anna", "math"); // teacher.printInfo(); // assertEquals("Этот человек с именем anna" + System.lineSeparator() + "Этот преподаватель с именем anna" + System.lineSeparator(), getOutput(), // "Метод printInfo() вызван у обекта класса Teacher, с полем name = anna"); // } // // @Test // public void getSubject() { // String subject = teacher.getSubjectName(); // assertEquals("math", subject, "Метод getSubject() вызван у обекта класса Teacher, с полем subjectName = math"); // } //}
package com.shiro.pojo; public class Dept extends BasePojo { private String deptId;//部门的主键id private String parentId;//父部门的主键 private String deptName;//部门名称 private int orderNo;//排序号 private int state;//部门状态,0表示停用,1表示启用 //表示和父部门的自关联关系 private Dept parentDept; public String getDeptId() { return deptId; } public void setDeptId(String deptId) { this.deptId = deptId; } public String getParentId() { return parentId; } public void setParentId(String parentId) { this.parentId = parentId; } public String getDeptName() { return deptName; } public void setDeptName(String deptName) { this.deptName = deptName; } public int getOrderNo() { return orderNo; } public void setOrderNo(int orderNo) { this.orderNo = orderNo; } public int getState() { return state; } public void setState(int state) { this.state = state; } public Dept getParentDept() { return parentDept; } public void setParentDept(Dept parentDept) { this.parentDept = parentDept; } }
import processing.core.PImage; import java.util.List; public abstract class WorldEntity { private String id; private Point position; private List<PImage> images; private int imageIndex; public WorldEntity(String id, Point position, List<PImage> images) { this.id = id; this.position = position; this.images = images; } public String getId() { return id; } public Point getPosition() { return position; } public void setPosition(Point p) { position = p; } public List<PImage> getImages() { return images; } public int getImageIndex() { return imageIndex; } public void nextImage() { imageIndex = (imageIndex + 1) % images.size(); } public PImage getCurrentImage(Object entity) { if (entity instanceof WorldEntity) { return (images.get(((WorldEntity)entity).getImageIndex())); } else { throw new UnsupportedOperationException( String.format("getCurrentImage not supported for %s", entity)); } } }
package main; import net.egork.collections.FenwickTree; import net.egork.graph.Graph; import net.egork.utils.io.InputReader; import net.egork.utils.io.OutputWriter; public class TaskE { FenwickTree root = new FenwickTree(211111); FenwickTree tree = new FenwickTree(211111); Graph g; int n, m, a, b; int[] from_root = new int[211111]; int[] depth = new int[211111]; int[] mask = new int[211111]; //int[] vis = new int[111111]; int fun(int node, int d, int par) { //if(vis[node]==1)return 0; mask[node] = a; a++; //System.out.println(node); from_root[mask[node]] = d; int id = g.firstOutbound(node); int mx = 0; while (id != -1) { int to = g.destination(id); if (par == to) { id = g.nextOutbound(id); continue; } mx = Math.max(mx, 1 + fun(to, d + 1, node)); id = g.nextOutbound(id); if(node==1){ a++; } } return depth[mask[node]] = mx; } public void solve(int testNumber, InputReader in, OutputWriter out) { //System.out.print("hic"); n = in.readInt(); m = in.readInt(); g = new Graph(n + 1); for (int i = 0; i < n - 1; i++) { a = in.readInt(); b = in.readInt(); g.addSimpleEdge(a, b); g.addSimpleEdge(b, a); } a = 1; fun(1, 1, -1); for (int i = 0; i < m; i++) { int t, v, x, d, mx; t = in.readInt(); if (t == 0) { v = in.readInt(); x = in.readInt(); d = in.readInt(); if (v == 1) { root.add(1, x); // out.printLine("root plus " + x); // out.printLine("root minus " + (d + 1)); root.add(d + 1, -x); continue; } if (d + 1 >= from_root[mask[v]]) { mx = d+2-from_root[mask[v]]; if(mx<=from_root[mask[v]]) { tree.add(mask[v] - (from_root[mask[v]]-mx) + 1, x); // out.printLine("tree add # "+(mask[v] - (from_root[mask[v]]-mx) + 1)+" "+x); } else{ tree.add(Math.min(mask[v] + (mx - from_root[mask[v]])+1, mask[v] + depth[mask[v]] + 1), x); // out.printLine("tree add * "+(Math.min(mask[v] + (mx - from_root[mask[v]])+1, mask[v] + depth[mask[v]] + 1))+" "+x); } root.add(1,x); // out.printLine("root plus " + x); // out.printLine("root minus " + ( mx + 1)); root.add(mx+1, -x); } else { tree.add(mask[v] - d, x); // out.printLine("tree plus " + (mask[v] - d) + " " + x); } mx = Math.min(d, depth[mask[v]] + 1); tree.add(mask[v] + mx, -x); // out.printLine("tree minus " + (mask[v] + mx) + " " + x); } else { //out.print("hic\n"); // out.printLine("TREEEE "+tree.get(2,3)); v = in.readInt(); if (v != 1) { long fr=root.get(1, from_root[mask[v]]); long tr= tree.get(mask[v] - (from_root[mask[v]] - 2), mask[v]); out.printLine("from root "+fr); out.printLine(" from tree "+tr); out.printLine(" tree "+mask[v]+" "+(from_root[mask[v]] - 2)); out.printLine(fr +tr); } else { long fr=root.get(1, from_root[mask[v]]); // out.printLine("from root "+fr); out.printLine(fr); } } } } }
package com.nbc.model; import org.bson.types.ObjectId; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; import java.io.Serializable; /** * LogItem * * @author <a href="mailto:nbccong@inetcloud.vn">Chi Cong Nguyen</a> * @version $Id: LogItem.java Dec 28, 2016 23:50:21 nbccong $ * @since 1.0 */ @Document(collection = "log-items") public class LogItem implements Serializable { @Id private ObjectId id; private String message; private String timestamp; public LogItem() {} public LogItem(String message) { this.message = message; } public ObjectId getId() { return id; } public void setId(ObjectId id) { this.id = id; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getTimestamp() { return timestamp; } public void setTimestamp(String timestamp) { this.timestamp = timestamp; } @Override public String toString() { return "LogItem{" + "id=" + id + ", message='" + message + '\'' + ", timestamp='" + timestamp + '\'' + '}'; } }
package com.spring.shopping.qna; public interface QNAService { public void writeQNA(String id, QNAVO qnaVO) throws Exception; public void writeQNAReview(QNAVO qnaVO) throws Exception; }
package MyWork.Mappers; import MyWork.Descriptors.AttributeDescriptor; import MyWork.Descriptors.DefaultDescriptor; import MyWork.Descriptors.ReferenceDescriptor; import MyWork.Domain.User; import java.lang.reflect.Type; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; public class DescriptorMapper { protected List<AttributeDescriptor> CreateAttributeDescriptors() { List<AttributeDescriptor> result = new ArrayList<>(); result.add(new DefaultDescriptor("remoteId", GetClass(), int.class)); result.add(new DefaultDescriptor("createdDate", GetClass(), ZonedDateTime.class)); result.add(new DefaultDescriptor("lastChangedDate", GetClass(), ZonedDateTime.class)); result.add(new ReferenceDescriptor("createdBy", GetClass(), User.class)); result.add(new ReferenceDescriptor("lastChangedBy", GetClass(), User.class)); result.add(new DefaultDescriptor("optimisticLockVersion", GetClass(), int.class)); return result; } private Type GetClass() { return DescriptorMapper.class; } }
package com.codecool.zsana.scrumtrackertest.scrumtrackertest; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; public class Homepage extends Basepage { @FindBy(xpath = "//a[.='Sign in / up']") private WebElement signInUpButton; @FindBy(xpath = "//div[@class='text-link']") private WebElement logoutButton; @FindBy(xpath = "//*[@id=\"root\"]/div/div/h1") private WebElement heading; @FindBy(xpath = "//*[@id=\"root\"]/div/nav/ul") private WebElement navbar; @FindBy(xpath = "//a[contains(.,'Home')]") private WebElement homeButton; @FindBy(xpath = "//a[contains(.,'Projects')]") private WebElement projectsButton; Homepage(WebDriver driver) { super(driver); } public WebElement getSignInUpButton() { return signInUpButton; } public WebElement getLogoutButton() { return getLogoutButton(); } public WebElement getProjectsButton() { return projectsButton; } public WebElement getHeading() { return heading; } public WebElement getNavbar() { return navbar; } public WebElement getHomeButton() { return homeButton; } }
package com.example.myreadproject8.greendao.entity.rule.convert; import com.example.myreadproject8.greendao.entity.rule.FindRule; import com.example.myreadproject8.util.gson.GsonExtensionsKt; import org.greenrobot.greendao.converter.PropertyConverter; /** * @author fengyue * @date 2021/2/8 18:28 */ public class FindRuleConvert implements PropertyConverter<FindRule, String> { @Override public FindRule convertToEntityProperty(String databaseValue) { return GsonExtensionsKt.getGSON().fromJson(databaseValue, FindRule.class); } @Override public String convertToDatabaseValue(FindRule entityProperty) { return GsonExtensionsKt.getGSON().toJson(entityProperty); } }
package com.tencent.mm.plugin.fav.ui; import com.tencent.mm.plugin.fav.a.b; class FavBaseUI$1 implements Runnable { final /* synthetic */ FavBaseUI iYp; FavBaseUI$1(FavBaseUI favBaseUI) { this.iYp = favBaseUI; } public final void run() { b.aKP(); } }
package rhtn_homework; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class BOJ_2002_추월 { private static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int N = Integer.parseInt(br.readLine()); HashMap<String, Integer> map = new HashMap<>(); for (int i = 0; i < N; i++) { map.put(br.readLine(), i); } //System.out.println(map); int[] arr = new int[N]; for (int i = 0; i < N; i++) { arr[i] = map.get(br.readLine()); } System.out.println(Arrays.toString(arr)); int ans=0; for (int i = 0; i < N; i++) { for (int j = i+1; j < N; j++) { // 현재 숫자가 뒤에있는 숫자보다 크다면 새치기를 무조건 한거다 if(arr[i] > arr[j]) { ans++; break; } } } System.out.println(ans); } }
package kr.ko.nexmain.server.MissingU.msgbox.model; import kr.ko.nexmain.server.MissingU.common.model.CommReqVO; public class MsgBoxConversVO extends CommReqVO { private static final long serialVersionUID = -4856053239078539076L; /** 상대 ID */ private Integer targetMemberId = 0; public Integer getTargetMemberId() { return targetMemberId; } public void setTargetMemberId(Integer targetMemberId) { this.targetMemberId = targetMemberId; } }
package com.tencent.mm.booter; import com.tencent.mm.booter.z.a; import com.tencent.mm.g.a.pa; import com.tencent.mm.sdk.b.b; import com.tencent.mm.sdk.b.c; import com.tencent.mm.sdk.platformtools.x; import com.tencent.mm.storage.bd; class z$1 extends c<pa> { final /* synthetic */ z cXX; z$1(z zVar) { this.cXX = zVar; this.sFo = pa.class.getName().hashCode(); } public final /* synthetic */ boolean a(b bVar) { pa paVar = (pa) bVar; if (paVar instanceof pa) { bd bdVar = paVar.bZV.bGS; z zVar = this.cXX; if (!(zVar.cXL == null || zVar.cXN.contains(Long.valueOf(bdVar.field_msgId)) || !zVar.cXL.cXY.equals(bdVar.field_talker))) { zVar.cXN.add(Long.valueOf(bdVar.field_msgId)); a aVar = zVar.cXL; aVar.cYf++; x.i("MicroMsg.StayTimeReport", "sendMsg msgType:%d, SendCnt:%d", new Object[]{Integer.valueOf(bdVar.getType()), Integer.valueOf(zVar.cXL.cYf)}); } } return false; } }
package android.support.v4.app; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.support.v4.app.z.a; import android.support.v4.app.z.e; import android.support.v4.app.z.i; import android.support.v4.app.z.r; import android.widget.RemoteViews; import java.util.ArrayList; public class z$d { public Context mContext; Bundle mExtras; int mPriority; boolean pA = true; public boolean pB; public r pC; public CharSequence pD; int pE; int pF; boolean pG; String pH; boolean pI; String pJ; public ArrayList<a> pK = new ArrayList(); public boolean pL = false; public String pM; int pN = 0; int pO = 0; Notification pP; public Notification pQ = new Notification(); public ArrayList<String> pR; public CharSequence ps; public CharSequence pt; public PendingIntent pu; PendingIntent pv; RemoteViews pw; public Bitmap px; public CharSequence py; public int pz; public z$d(Context context) { this.mContext = context; this.pQ.when = System.currentTimeMillis(); this.pQ.audioStreamType = -1; this.mPriority = 0; this.pR = new ArrayList(); } public final z$d g(long j) { this.pQ.when = j; return this; } public final z$d Y(int i) { this.pQ.icon = i; return this; } public final z$d b(CharSequence charSequence) { this.ps = e(charSequence); return this; } public final z$d c(CharSequence charSequence) { this.pt = e(charSequence); return this; } public final z$d b(int i, int i2, boolean z) { this.pE = i; this.pF = i2; this.pG = z; return this; } public final z$d d(CharSequence charSequence) { this.pQ.tickerText = e(charSequence); return this; } public final z$d u(boolean z) { j(16, z); return this; } public final void j(int i, boolean z) { Notification notification; if (z) { notification = this.pQ; notification.flags |= i; return; } notification = this.pQ; notification.flags &= i ^ -1; } public final z$d a(int i, CharSequence charSequence, PendingIntent pendingIntent) { this.pK.add(new a(i, charSequence, pendingIntent)); return this; } @Deprecated public final Notification getNotification() { return build(); } public final Notification build() { i by = z.by(); e eVar = new e(); return by.b(this); } protected static CharSequence e(CharSequence charSequence) { if (charSequence != null && charSequence.length() > 5120) { return charSequence.subSequence(0, 5120); } return charSequence; } }
/* * The purpose of this lab is to learn about the importance of * distinguishing between an integer and a double, i.e. 1.0 and 1 * * Author: Victor (Zach) Johnson * Date: 9/2/17 */ package chapter1; public class Ex1_07 { public static void main(String[] args) { System.out.println(4 * (1.0 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11) + (1.0/13))); } }
package com.example.demo.api.transaction.request; import com.example.demo.core.model.request.BaseRequest; public class TransactionDetailRequest extends BaseRequest { private String transactionId; public String getTransactionId() { return transactionId; } public void setTransactionId(String transactionId) { this.transactionId = transactionId; } }
package exercicios.exercicio01; public class App { public static void main(String[] args) { Animal animal = new Animal("Jullie", "Cão - Lhasa Apso", "13/03/2013"); System.out.println(animal); } }
package com.lingnet.vocs.action.statistics; import com.lingnet.common.action.BaseAction; /** * 地区统计分析 * * @ClassName: AreaStatisticsAction * @Description: TODO * @author xues * @date 2017年6月13日 上午8:12:16 * */ public class AreaStatisticsAction extends BaseAction { private static final long serialVersionUID = -7274943230009869656L; public String charts() { return "charts"; } }
package com.travelportal.vm; import java.util.List; import com.travelportal.domain.agent.AgentRegistration; public class SpecificMarkupInfoVM { public int specificMarkupId; public Long supplier; public String agentCode; public String agentfirstName; public String companyName; public int countryCode; public String CountryName; public int currencyCode; public String currencyName; public String selected; public Double flat; public Double percent; public Long rateId; public String rateName; public String fromDate; public String toDate; public int getSpecificMarkupId() { return specificMarkupId; } public void setSpecificMarkupId(int specificMarkupId) { this.specificMarkupId = specificMarkupId; } public Long getRateId() { return rateId; } public void setRateId(Long rateId) { this.rateId = rateId; } public String getRateName() { return rateName; } public void setRateName(String rateName) { this.rateName = rateName; } public Long getSupplier() { return supplier; } public void setSupplier(Long supplier) { this.supplier = supplier; } public String getAgentCode() { return agentCode; } public void setAgentCode(String agentCode) { this.agentCode = agentCode; } public int getCountryCode() { return countryCode; } public void setCountryCode(int countryCode) { this.countryCode = countryCode; } public String getCountryName() { return CountryName; } public void setCountryName(String countryName) { CountryName = countryName; } public int getCurrencyCode() { return currencyCode; } public void setCurrencyCode(int currencyCode) { this.currencyCode = currencyCode; } public String getCurrencyName() { return currencyName; } public void setCurrencyName(String currencyName) { this.currencyName = currencyName; } public String getSelected() { return selected; } public void setSelected(String selected) { this.selected = selected; } public Double getFlat() { return flat; } public void setFlat(Double flat) { this.flat = flat; } public Double getPercent() { return percent; } public void setPercent(Double percent) { this.percent = percent; } public String getAgentfirstName() { return agentfirstName; } public void setAgentfirstName(String agentfirstName) { this.agentfirstName = agentfirstName; } public String getFromDate() { return fromDate; } public void setFromDate(String fromDate) { this.fromDate = fromDate; } public String getToDate() { return toDate; } public void setToDate(String toDate) { this.toDate = toDate; } public String getCompanyName() { return companyName; } public void setCompanyName(String companyName) { this.companyName = companyName; } }
package com.xsf.example.atomic; import com.xsf.annotation.ThreadSafe; import lombok.extern.slf4j.Slf4j; import java.util.concurrent.atomic.AtomicReference; /** * @Author:xiusifeng * @Date:2018/4/23 * @Time:9:53 */ @Slf4j @ThreadSafe public class AtomicReferenceExample { private static AtomicReference<Integer> count = new AtomicReference<>(0); public static void main(String[] args) { count.compareAndSet(0, 2); count.compareAndSet(1, 3); count.compareAndSet(2, 4); count.compareAndSet(3, 5); count.compareAndSet(4, 6); count.compareAndSet(5, 7); log.info("count:{}", count); } }
package com.canby.weather; import com.canby.observer.Observer; import com.google.inject.Inject; import java.util.logging.Level; import java.util.logging.Logger; /** * Created by acanby on 12/10/2014. */ public class WeatherWidget implements Observer { private static final Logger LOGGER = Logger.getLogger(WeatherWidget.class.getName()); private WeatherStation weatherStation; private float temperature; private float humidity; private float pressure; @Inject public WeatherWidget() { } public void addObservable(WeatherStation weatherStation) { this.weatherStation = weatherStation; weatherStation.addObserver(this); } public WeatherStation removeObserable() { WeatherStation toReturn = this.weatherStation; this.weatherStation.removeObserver(this); this.weatherStation = null; return toReturn; } @Override public void setUpdated() { LOGGER.log(Level.INFO, "Update! Going to change the measurements on the widget."); LOGGER.log(Level.FINE, "{} {} {}", new Object[] {temperature, humidity, pressure}); this.temperature = weatherStation.getTemperature(); this.humidity = weatherStation.getHumidity(); this.pressure = weatherStation.getPressure(); } public float getTemperature() { return temperature; } public float getHumidity() { return humidity; } public float getPressure() { return pressure; } }
/* * The purpose of this lab is to learn about assigning values to variables * and using and calling the data to solve formulas. * * Author: Victor (Zach) Johnson * Date: 9//17 */ package chapter2; import java.util.Scanner; public class Ex2_01 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double f = 0, c = 0; System.out.println("Enter a degree in Celcius: "); c = input.nextDouble(); f = ((9 /5.0) * c + 32); System.out.println("Your degree in Farenheit is: " + f); } }
import javax.xml.crypto.dsig.Manifest; import jdk.javadoc.internal.tool.Main; public class countwords { public static void main(String[] args){ String s ="welcome to java"; String[] s1 = s.split(""); int len=0; for(String t:s1) { len++; } System.out.println(len); } }
package com.mx.profuturo.bolsa.model.service.vacancies.vo; import java.util.ArrayList; public class ResumenPlazaMaestraVO { private Integer idVacante; private String sede; private Integer idSede; private Integer plazasAbiertas; private String gerencia; private ArrayList<String> analistAsignado; public Integer getIdSede() { return idSede; } public void setIdSede(Integer idSede) { this.idSede = idSede; } public String getGerencia() { return gerencia; } public void setGerencia(String gerencia) { this.gerencia = gerencia; } public ArrayList<String> getAnalistAsignado() { return analistAsignado; } public void setAnalistAsignado(ArrayList<String> analistAsignado) { this.analistAsignado = analistAsignado; } public Integer getIdVacante() { return idVacante; } public void setIdVacante(Integer idVacante) { this.idVacante = idVacante; } public String getSede() { return sede; } public void setSede(String sede) { this.sede = sede; } public Integer getPlazasAbiertas() { return plazasAbiertas; } public void setPlazasAbiertas(Integer plazasAbiertas) { this.plazasAbiertas = plazasAbiertas; } }
package cn.yong.zheng.batch.control; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.orm.jpa.EntityScan; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @EnableJpaRepositories("cn.yong.zheng.batch.dao") @ComponentScan("cn.yong.zheng.batch") @EntityScan("cn.yong.zheng.batch.entity") @SpringBootApplication public class SpringBootJspApplication extends SpringBootServletInitializer{ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(SpringBootJspApplication.class); } public static void main(String[] args) throws Exception { SpringApplication.run(SpringBootJspApplication.class, args); } }
package de.raidcraft.skillsandeffects.pvp.effects.misc; import de.raidcraft.RaidCraft; import de.raidcraft.skills.SkillsPlugin; import de.raidcraft.skills.api.character.CharacterTemplate; import de.raidcraft.skills.api.combat.EffectType; import de.raidcraft.skills.api.combat.ProjectileType; import de.raidcraft.skills.api.effect.EffectInformation; import de.raidcraft.skills.api.effect.types.ExpirableEffect; import de.raidcraft.skills.api.exceptions.CombatException; import de.raidcraft.skills.api.persistance.EffectData; import de.raidcraft.skills.api.trigger.TriggerHandler; import de.raidcraft.skills.api.trigger.Triggered; import de.raidcraft.skills.trigger.ProjectileLaunchTrigger; import de.raidcraft.skillsandeffects.pvp.skills.bow.Multishot; import org.bukkit.Bukkit; /** * @author Silthus */ @EffectInformation( name = "Multi Shot", description = "Verschiesst mehrere Pfeile auf einmal.", types = {EffectType.PHYSICAL, EffectType.HARMFUL, EffectType.DAMAGING} ) public class MultishotEffect extends ExpirableEffect<Multishot> implements Triggered { public MultishotEffect(Multishot source, CharacterTemplate target, EffectData data) { super(source, target, data); } @TriggerHandler public void onProjectileLaunch(ProjectileLaunchTrigger trigger) throws CombatException { if (ProjectileType.valueOf(trigger.getEvent().getEntity()) != getSource().getType()) { return; } int amount = getSource().getAmount(); for (int i = 1; i <= amount; i++) { Bukkit.getScheduler().runTaskLater(RaidCraft.getComponent(SkillsPlugin.class), new Runnable() { @Override public void run() { try { getSource().rangedAttack(getSource().getType()).run(); } catch (CombatException e) { warn(e.getMessage()); } } }, 2 * i); } remove(); } @Override protected void apply(CharacterTemplate target) throws CombatException { info("Du legst mehrere Pfeile in deinen Bogen ein."); } @Override protected void renew(CharacterTemplate target) throws CombatException { } @Override protected void remove(CharacterTemplate target) throws CombatException { } }
package com.lvt.demo.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; import org.apache.commons.lang3.StringUtils; import org.springframework.validation.FieldError; import java.util.ArrayList; import java.util.List; @Service public class MessageService { @Autowired private Environment environment; @Autowired private MessageSource messageSource; public String getCode(String message) { String code = messageSource.getMessage(message + ".code", null, null); if (StringUtils.isEmpty(code)) { return message + ".code"; } return code; } public String getMessage(String message) { String msg = environment.getProperty(message + ".message"); if (StringUtils.isEmpty(msg)) { return message + ".message"; } return msg; } public String getMessage(String message, FieldError f) { String fieldName = f.getField().replaceAll("(.)(\\p{Upper})","$1_$2").toLowerCase(); List<String> param = new ArrayList<>(); String msg = messageSource.getMessage(message + ".message", param.stream().toArray(String[] :: new), null); if (StringUtils.isEmpty(msg)) { return message + ".message"; } return msg; } }
package FirstDay; import org.junit.Test; import static org.junit.Assert.assertEquals; public class AdditionTest { int n1=55; int n2=10; Addition a = new Addition(); @Test public void testAddition() { assertEquals(65,a.add(n1,n2)); } }
package com.mimi.mimigroup.db; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.provider.ContactsContract; import android.util.Log; import com.mimi.mimigroup.model.DM_Customer; import com.mimi.mimigroup.model.DM_Customer_Distance; import com.mimi.mimigroup.model.DM_Customer_Search; import com.mimi.mimigroup.model.DM_Employee; import com.mimi.mimigroup.model.DM_Product; import com.mimi.mimigroup.model.DM_Season; import com.mimi.mimigroup.model.DM_Tree; import com.mimi.mimigroup.model.DM_TreeStages; import com.mimi.mimigroup.model.DM_Tree_Disease; import com.mimi.mimigroup.model.HT_PARA; import com.mimi.mimigroup.model.DM_Province; import com.mimi.mimigroup.model.DM_District; import com.mimi.mimigroup.model.DM_Ward; import com.mimi.mimigroup.model.QR_QRSCAN; import com.mimi.mimigroup.model.SM_CustomerPay; import com.mimi.mimigroup.model.SM_Order; import com.mimi.mimigroup.model.SM_OrderDelivery; import com.mimi.mimigroup.model.SM_OrderDeliveryDetail; import com.mimi.mimigroup.model.SM_OrderDetail; import com.mimi.mimigroup.model.SM_OrderStatus; import com.mimi.mimigroup.model.SM_PlanSale; import com.mimi.mimigroup.model.SM_PlanSaleDetail; import com.mimi.mimigroup.model.SM_ReportSaleRep; import com.mimi.mimigroup.model.SM_ReportSaleRepActivitie; import com.mimi.mimigroup.model.SM_ReportSaleRepDisease; import com.mimi.mimigroup.model.SM_ReportSaleRepMarket; import com.mimi.mimigroup.model.SM_ReportSaleRepSeason; import com.mimi.mimigroup.model.SM_ReportTech; import com.mimi.mimigroup.model.SM_ReportTechActivity; import com.mimi.mimigroup.model.SM_ReportTechCompetitor; import com.mimi.mimigroup.model.SM_ReportTechDisease; import com.mimi.mimigroup.model.SM_ReportTechMarket; import com.mimi.mimigroup.model.SM_VisitCard; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class DBGimsHelper extends SQLiteOpenHelper{ private Context mCxt; private static DBGimsHelper mInstance = null; private static final int DATABASE_VERSION=12; private static final String DATABASE_NAME="mimigroup_sm"; private DBGimsHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } public static DBGimsHelper getInstance(Context ctx) { /** * use the application context as suggested by CommonsWare. * this will ensure that you dont accidentally leak an Activitys * context (see this article for more information: * http://android-developers.blogspot.nl/2009/01/avoiding-memory-leaks.html) */ if (mInstance == null) { mInstance = new DBGimsHelper(ctx.getApplicationContext()); } return mInstance; } //UPDATE DB INFOR @Override public void onCreate(SQLiteDatabase db) { /*<<THONG TIN TABLE>> * 1-tblTHIETBI,2-tblDMTINH,3-tblDMHUYEN,4-tblDMXA, 5-tblDMCAYTRONG,6-tblDMGIAIDOAN,7-tblDMDICHHAI,8-tblDMNHOMSP,9-tblDMSANPHAM, 10-tblDMTANSUAT,11-tblDMMUCDO,12-tblDMDPDOITHU,13-tblDMNVKH 14-tblKHBH,15-tblCTKHBH,16-tblKHACHHANG,17-tblNHACC,18-tblLICHTHAM, 19-tblTHETHAM,20-tblTHITRUONG,21- tblDOITHU,22-tblTTSANPHAM,23-tblDUBAO <<END>> */ //<<THAM SỐ HỆ THỐNG>>// INTEGER PRIMARY KEY String sqlCMM="CREATE TABLE HT_PARA(" + "PARA_NAME VARCHAR(50),"+ "PARA_VAL VARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_PROVINCE(Provinceid INTEGER PRIMARY KEY,"+ "ProvinceCode VARCHAR(10),"+ "Province VARCHAR(50),"+ "ZoneCode VARCHAR(10))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_DISTRICT(Districtid INTEGER PRIMARY KEY,"+ "Provinceid INTEGER,"+ "District VARCHAR(50),"+ "DistrictCode VARCHAR(10))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_WARD(Wardid INTEGER PRIMARY KEY,"+ "Districtid INTEGER,"+ "Ward VARCHAR(50),"+ "WardCode VARCHAR(10))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_PRODUCT_GROUP(ProductGroupid VARCHAR(15) PRIMARY KEY,"+ "ProductGroup VARCHAR(50),"+ "ProductGroupCode VARCHAR(10))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_PRODUCT(ProductCode VARCHAR(15) PRIMARY KEY,"+ "ProductGroupID VARCHAR(15),"+ "ProductName VARCHAR(50),"+ "Unit VARCHAR(30),"+ "Spec VARCHAR(30),"+ "ConvertKgl FLOAT,"+ "ConvertBox FLOAT,"+ "isMain BIT)"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_CUSTOMER(Customerid VARCHAR(50)PRIMARY KEY,"+ "Employeeid VARCHAR(50),"+ "CustomerCode VARCHAR(15),"+ "CustomerName VARCHAR(150),"+ "ShortName VARCHAR(50),"+ "Represent VARCHAR(70),"+ "Provinceid INTEGER,"+ "Districtid INTEGER,"+ "Wardid INTEGER,"+ "Street VARCHAR(250),"+ "Address VARCHAR(250),"+ "Tax VARCHAR(15),"+ "Tel VARCHAR(15),"+ "Fax VARCHAR(15),"+ "Email VARCHAR(50),"+ "IsLevel INTEGER,"+ "VisitSchedule VARCHAR(10),"+ "Ranked VARCHAR(10),"+ "ExtCustomer BIT,"+ "Longitude FLOAT,"+ "Latitude FLOAT,"+ "LongitudeTemp FLOAT,"+ "LatitudeTemp FLOAT,"+ "Scope FLOAT,"+ "LocationAddress VARCHAR(255),"+ "LocationAddressTemp VARCHAR(255),"+ "Notes VARCHAR(200),"+ "IsSupport BIT,"+ "EditStatus INTEGER)"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_CUSTOMER_SUPPLIER(Supplierid VARCHAR(50),"+ "Customerid VARCHAR(50),"+ "Notes VARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE QR_QRSCAN(Qrscanid VARCHAR(50),"+ "Customerid VARCHAR(50),"+ "CommandNo VARCHAR(15),"+ "Qrid VARCHAR(50),"+ "ProductCode VARCHAR(15),"+ "ProductName VARCHAR(70),"+ "Unit VARCHAR(30),"+ "Specification VARCHAR(50),"+ "ScanNo INTEGER,"+ "ScanDay DATETIME,"+ "Longitude FLOAT,"+ "Latitude FLOAT,"+ "LocationAddress VARCHAR(255),"+ "ScanSupportID VARCHAR(50),"+ "Imei VARCHAR(50),"+ "ImeiSim VARCHAR(50),"+ "ScanType VARCHAR(5),"+ "SyncDay DATETIME,"+ "IsSync BIT)"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE QR_QRSCAN_HIS(Scanhisid VARCHAR(50),"+ "Customerid VARCHAR(50),"+ "CommandNo VARCHAR(15),"+ "Qrid VARCHAR(50),"+ "ProductCode VARCHAR(15),"+ "ProductName VARCHAR(70),"+ "Unit VARCHAR(30),"+ "Specification VARCHAR(50),"+ "ScanNo INTEGER,"+ "ScanDay DATETIME,"+ "Longitude FLOAT,"+ "Latitude FLOAT,"+ "LocationAddress VARCHAR(255),"+ "Employee VARCHAR(100))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_CUSTOMER_LOCATION("+ "Customerid VARCHAR(50),"+ "CustomerCode VARCHAR(15),"+ "CustomerName VARCHAR(150),"+ "LongitudeScan FLOAT,"+ "LatitudeScan FLOAT,"+ "LocationAddressScan VARCHAR(255)," + "Distince FLOAT)"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE SM_VISITCARD("+ "VisitCardID VARCHAR(50),"+ "VisitDay DATETIME,"+ "CustomerID VARCHAR(50),"+ "VisitType VARCHAR(5),"+ "VisitTime DATETIME,"+ "Longitude FLOAT,"+ "Latitude FLOAT,"+ "LocationAddress VARCHAR(255)," + "VisitNotes VARCHAR(255),"+ "IsSync BIT,"+ "SyncDay DATETIME)"; db.execSQL(sqlCMM); // addTrace(db); sqlCMM="CREATE TABLE DM_EMPLOYEE("+ "Employeeid VARCHAR(50),"+ "EmployeeCode VARCHAR(15),"+ "EmployeeName VARCHAR(120),"+ "Notes VARCHAR(255))"; db.execSQL(sqlCMM); /////////////////////////////////////// TIVA /////////////////////////////////// // DM_ProductPrice sqlCMM = "CREATE TABLE DM_PRODUCT_PRICE(" + "PriceID nvarchar(50)," + "CustomerID nvarchar(50)," + "ProvinceCode nvarchar(50)," + "ProductID nvarchar(50)," + "OriginPrice numeric(18, 3)," + "SalePrices numeric(18, 3)," + "SalePrice numeric(18, 3)," + "IsActive int ," + "IsActiveDate datetime," + "Sync varchar(500))"; db.execSQL(sqlCMM); //DM_SaleOrder sqlCMM = "CREATE TABLE SM_ORDER(" + "OrderID VARCHAR(50) PRIMARY KEY," + "OrderCode VARCHAR(50)," + "CustomerID VARCHAR(50), " + "OrderDate DATETIME,"+ "RequestDate DATETIME," + "MaxDebt INTEGER," + "OriginMoney FLOAT," + "VAT FLOAT," + "VATMoney FLOAT," + "TotalMoney FLOAT," + "OrderStatus INTEGER," + "OrderNotes VARCHAR(255), " + "ApproveDate DATETIME," + "HandleStaff VARCHAR(100)," + "DeliveryDesc VARCHAR(500)," + "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "SeqnoCode INTEGER," + "IsSample BIT,"+ "IsPost BIT,"+ "PostDay DATETIME)"; db.execSQL(sqlCMM); // SALE ORDER DETAIL,Notes2: TreeList sqlCMM = "CREATE TABLE SM_ORDER_DETAIL(" + "OrderDetailID VARCHAR(50) PRIMARY KEY," + "OrderID VARCHAR(50)," + "ProductID VARCHAR(50)," + "ProductCode VARCHAR(50)," + "ProductName VARCHAR(100)," + "Unit VARCHAR(30)," + "Spec VARCHAR(50),"+ "ConvertBox FLOAT,"+ "Amount INTEGER," + "AmountBox FLOAT,"+ "Price FLOAT," + "OriginMoney FLOAT,"+ "Notes VARCHAR(255)," + "Notes2 VARCHAR(255))"; db.execSQL(sqlCMM); // DELIVERY ORDER sqlCMM = "CREATE TABLE SM_DELIVERY_ORDER(" + "DeliveryOrderID VARCHAR(50) PRIMARY KEY," + "OrderID VARCHAR(50)," + "TransportCode VARCHAR(50)," + "NumberPlate VARCHAR(50)," + "CarType VARCHAR(100)," + "DeliveryStaff VARCHAR(100)," + "DeliveryNum INTEGER," + "DeliveryDate DATETIME," + "HandlingStaff VARCHAR(100)," + "HandlingDate DATETIME," + "TotalMoney FLOAT,"+ "DeliveryDesc VARCHAR(1500))"; db.execSQL(sqlCMM); //DELIVERYDETAIL sqlCMM = "CREATE TABLE SM_DELIVERY_ORDER_DETAIL(" + "DeliveryOrderDetailID VARCHAR(50) PRIMARY KEY," + "DeliveryOrderID VARCHAR(50)," + "ProductCode VARCHAR(50)," + "ProductName VARCHAR(100)," + "Unit VARCHAR(30)," + "Spec VARCHAR(50),"+ "Amount INTEGER," + "AmountBox FLOAT,"+ "Price FLOAT," + "OriginMoney FLOAT,"+ "Notes VARCHAR(255))"; db.execSQL(sqlCMM); /////////////////////////////////////////END TIVA /////////////////////////////////// ////////////GIAI DOAN 2////////// sqlCMM="CREATE TABLE SM_CUSTOMER_PAY(PayID VARCHAR(50) PRIMARY KEY,"+ "PayCode VARCHAR(20),"+ "PayDate DATETIME,"+ "PayName VARCHAR(100),"+ "CustomerID VARCHAR(50),"+ "PayMoney FLOAT,"+ "PayPic VARCHAR(255),"+ "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "PayStatus INTEGER," + "PayNotes VARCHAR(255)," + "IsPost BIT,"+ "PostDay DATETIME)"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_TREE(TreeID INTEGER PRIMARY KEY,"+ "TreeCode VARCHAR(15),"+ "TreeGroupCode VARCHAR(15),"+ "TreeName VARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_TREE_DISEASE(DiseaseID INTEGER PRIMARY KEY,"+ "TreeID INTEGER,"+ "DiseaseCode VARCHAR(15),"+ "DiseaseName VARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_SEASON(SeasonID INTEGER PRIMARY KEY,"+ "SeasonCode VARCHAR(15),"+ "SeasonName VARCHAR(50))"; db.execSQL(sqlCMM); //[[[[REPORT-TECH:BÁO CÁO KỸ THUẬT]]]] sqlCMM = "CREATE TABLE SM_REPORT_TECH(ReportTechID VARCHAR(50) PRIMARY KEY," + "ReportCode VARCHAR(20)," + "ReportName VARCHAR(50)," + "ReportDay DATETIME," + "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "ReceiverList VARCHAR(255)," + "Notes VARCHAR(50)," + "IsStatus INTEGER," + "IsPost BIT," + "PostDay DATETIME)"; db.execSQL(sqlCMM); //THỊ TRƯỜNG sqlCMM = "CREATE TABLE SM_REPORT_TECH_MARKET(MarketID VARCHAR(50) PRIMARY KEY," + "ReportTechID VARCHAR(50)," + "Title VARCHAR(50)," + "Notes VARCHAR(200)," + "Useful VARCHAR(200)," + "Harmful VARCHAR(200))"; db.execSQL(sqlCMM); //DỊCH BỆNH sqlCMM = "CREATE TABLE SM_REPORT_TECH_DISEASE(DiseaseID VARCHAR(50) PRIMARY KEY," + "ReportTechID VARCHAR(50)," + "TreeCode VARCHAR(15)," + "StagesCode VARCHAR(15)," + "Title VARCHAR(50)," + "Acreage FLOAT," + "Disease VARCHAR(200)," + "Price FLOAT," + "Notes VARCHAR(200))"; db.execSQL(sqlCMM); // GIAI DOAN - CAY TRONG sqlCMM="CREATE TABLE DM_TREE_STAGES(StagesID INTEGER PRIMARY KEY,"+ "TreeID INTEGER,"+ "StagesCode VARCHAR(15),"+ "StagesName VARCHAR(50))"; db.execSQL(sqlCMM); //ĐỐI THỦ sqlCMM = "CREATE TABLE SM_REPORT_TECH_COMPETITOR(CompetitorID VARCHAR(50) PRIMARY KEY," + "ReportTechID VARCHAR(50)," + "CompetitorPic VARCHAR(255)," + "Title VARCHAR(50)," + "Notes VARCHAR(200)," + "Useful VARCHAR(200)," + "Harmful VARCHAR(200))"; db.execSQL(sqlCMM); //HOẠT ĐỘNG [ISTYPE=0:TRONG TUAN, 1: KẾ HOẠCH TUẦN TỚI] sqlCMM = "CREATE TABLE SM_REPORT_TECH_ACTIVITIE(ActivitieID VARCHAR(50) PRIMARY KEY," + "ReportTechID VARCHAR(50)," + "IsType INTEGER," + "Title VARCHAR(50)," + "Notes VARCHAR(200)," + "Achievement VARCHAR(200))"; db.execSQL(sqlCMM); //[[[[REPORT-SALEREP:BÁO CÁO SALES-REP]]]] sqlCMM = "CREATE TABLE SM_REPORT_SALEREP(ReportSaleID VARCHAR(50) PRIMARY KEY," + "ReportCode VARCHAR(20)," + "ReportName VARCHAR(50)," + "ReportDay DATETIME," + "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "ReceiverList VARCHAR(255)," + "Notes VARCHAR(50)," + "IsStatus INTEGER," + "IsPost BIT," + "PostDay DATETIME)"; db.execSQL(sqlCMM); //THỊ TRƯỜNG sqlCMM = "CREATE TABLE SM_REPORT_SALEREP_MARKET(MarketID VARCHAR(50) PRIMARY KEY," + "ReportSaleID VARCHAR(50)," + "CustomerID VARCHAR(50)," + "CompanyName VARCHAR(100)," + "ProductCode VARCHAR(20)," + "Notes VARCHAR(200)," + "Price FLOAT)"; db.execSQL(sqlCMM); //DỊCH BỆNH sqlCMM = "CREATE TABLE SM_REPORT_SALEREP_DISEASE(DiseaseID VARCHAR(50) PRIMARY KEY," + "ReportSaleID VARCHAR(50)," + "TreeCode VARCHAR(15)," + "Title VARCHAR(50)," + "Acreage FLOAT," + "Notes VARCHAR(200))"; db.execSQL(sqlCMM); //MÙA VỤ sqlCMM = "CREATE TABLE SM_REPORT_SALEREP_SEASON(SeasonID VARCHAR(50) PRIMARY KEY," + "ReportSaleID VARCHAR(50)," + "TreeCode VARCHAR(15)," + "SeasonCode VARCHAR(15)," + "Title VARCHAR(50)," + "Acreage FLOAT," + "Notes VARCHAR(200))"; db.execSQL(sqlCMM); //HOAT ĐỘNG - CÔNG VIỆC - LỊCH CÔNG TÁC: iStYPE: 0 : Công việc, 1: Lịch công tác sqlCMM = "CREATE TABLE SM_REPORT_SALEREP_ACTIVITIE(ActivitieID VARCHAR(50) PRIMARY KEY," + "ReportSaleID VARCHAR(50)," + "IsType VARCHAR(15)," + "Workday VARCHAR(15)," + "Title VARCHAR(50)," + "Place VARCHAR(100)," + "Notes VARCHAR(200))"; db.execSQL(sqlCMM); // KE HOACH BAN HANG sqlCMM = "CREATE TABLE SM_PLAN_SALE(PlanID VARCHAR(50) PRIMARY KEY," + "PlanCode NVARCHAR(20)," + "PlanDay DATETIME," + "StartDay DATETIME," + "EndDay DATETIME," + "PlanName NVARCHAR(50)," + "PostDay DATETIME," + "IsPost BIT," + "IsStatus INTEGER," + "Notes NVARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM = "CREATE TABLE SM_PLAN_SALE_DETAIL(PlanDetailID VARCHAR(50) PRIMARY KEY," + "PlanID NVARCHAR(50)," + "CustomerID NVARCHAR(50)," + "ProductCode NVARCHAR(20)," + "AmountBox FLOAT," + "Amount FLOAT," + "Notes NVARCHAR(255)," + "Notes2 NVARCHAR(255))"; db.execSQL(sqlCMM); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try { String sqlCMM=""; if (oldVersion <12) { sqlCMM="CREATE TABLE SM_CUSTOMER_PAY(PayID VARCHAR(50) PRIMARY KEY,"+ "PayCode VARCHAR(20),"+ "PayDate DATETIME,"+ "PayName VARCHAR(100),"+ "CustomerID VARCHAR(50),"+ "PayMoney FLOAT,"+ "PayPic VARCHAR(255),"+ "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "PayStatus INTEGER," + "PayNotes VARCHAR(255)," + "IsPost BIT,"+ "PostDay DATETIME)"; db.execSQL(sqlCMM); db.execSQL("DROP TABLE IF EXISTS DM_TREE"); sqlCMM="CREATE TABLE DM_TREE(TreeID INTEGER PRIMARY KEY,"+ "TreeCode VARCHAR(15),"+ "TreeGroupCode VARCHAR(15),"+ "TreeName VARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_TREE_DISEASE(DiseaseID INTEGER PRIMARY KEY,"+ "TreeID INTEGER,"+ "DiseaseCode VARCHAR(15),"+ "DiseaseName VARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM="CREATE TABLE DM_SEASON(SeasonID INTEGER PRIMARY KEY,"+ "SeasonCode VARCHAR(15),"+ "SeasonName VARCHAR(50))"; db.execSQL(sqlCMM); //[[[[REPORT-TECH:BÁO CÁO KỸ THUẬT]]]] sqlCMM="CREATE TABLE SM_REPORT_TECH(ReportTechID VARCHAR(50) PRIMARY KEY,"+ "ReportCode VARCHAR(20),"+ "ReportName VARCHAR(50),"+ "ReportDay DATETIME,"+ "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "ReceiverList VARCHAR(255),"+ "Notes VARCHAR(50),"+ "IsStatus INTEGER,"+ "IsPost BIT,"+ "PostDay DATETIME)"; db.execSQL(sqlCMM); //THỊ TRƯỜNG sqlCMM="CREATE TABLE SM_REPORT_TECH_MARKET(MarketID VARCHAR(50) PRIMARY KEY,"+ "ReportTechID VARCHAR(50),"+ "Title VARCHAR(50),"+ "Notes VARCHAR(200)," + "Useful VARCHAR(200),"+ "Harmful VARCHAR(200))"; db.execSQL(sqlCMM); //DỊCH BỆNH sqlCMM="CREATE TABLE SM_REPORT_TECH_DISEASE(DiseaseID VARCHAR(50) PRIMARY KEY,"+ "ReportTechID VARCHAR(50),"+ "TreeCode VARCHAR(15),"+ "StagesCode VARCHAR(15)," + "Title VARCHAR(50),"+ "Acreage FLOAT," + "Disease VARCHAR(200),"+ "Price FLOAT,"+ "Notes VARCHAR(200))"; db.execSQL(sqlCMM); // GIAI DOAN - CAY TRONG sqlCMM="CREATE TABLE DM_TREE_STAGES(StagesID INTEGER PRIMARY KEY,"+ "TreeID INTEGER,"+ "StagesCode VARCHAR(15),"+ "StagesName VARCHAR(50))"; db.execSQL(sqlCMM); //ĐỐI THỦ sqlCMM="CREATE TABLE SM_REPORT_TECH_COMPETITOR(CompetitorID VARCHAR(50) PRIMARY KEY,"+ "ReportTechID VARCHAR(50),"+ "CompetitorPic VARCHAR(255),"+ "Title VARCHAR(50),"+ "Notes VARCHAR(200),"+ "Useful VARCHAR(200),"+ "Harmful VARCHAR(200))"; db.execSQL(sqlCMM); //HOẠT ĐỘNG [ISTYPE=0:TRONG TUAN, 1: KẾ HOẠCH TUẦN TỚI] sqlCMM="CREATE TABLE SM_REPORT_TECH_ACTIVITIE(ActivitieID VARCHAR(50) PRIMARY KEY,"+ "ReportTechID VARCHAR(50),"+ "IsType INTEGER,"+ "Title VARCHAR(50),"+ "Notes VARCHAR(200),"+ "Achievement VARCHAR(200))"; db.execSQL(sqlCMM); //[[[[REPORT-SALEREP:BÁO CÁO SALES-REP]]]] sqlCMM="CREATE TABLE SM_REPORT_SALEREP(ReportSaleID VARCHAR(50) PRIMARY KEY,"+ "ReportCode VARCHAR(20),"+ "ReportName VARCHAR(50),"+ "ReportDay DATETIME,"+ "Longitude FLOAT," + "Latitude FLOAT," + "LocationAddress VARCHAR(255)," + "ReceiverList VARCHAR(255),"+ "Notes VARCHAR(50),"+ "IsStatus INTEGER,"+ "IsPost BIT,"+ "PostDay DATETIME)"; db.execSQL(sqlCMM); //THỊ TRƯỜNG sqlCMM="CREATE TABLE SM_REPORT_SALEREP_MARKET(MarketID VARCHAR(50) PRIMARY KEY,"+ "ReportSaleID VARCHAR(50),"+ "CustomerID VARCHAR(50),"+ "CompanyName VARCHAR(100)," + "ProductCode VARCHAR(20),"+ "Notes VARCHAR(200),"+ "Price FLOAT)"; db.execSQL(sqlCMM); //DỊCH BỆNH sqlCMM="CREATE TABLE SM_REPORT_SALEREP_DISEASE(DiseaseID VARCHAR(50) PRIMARY KEY,"+ "ReportSaleID VARCHAR(50),"+ "TreeCode VARCHAR(15),"+ "Title VARCHAR(50)," + "Acreage FLOAT,"+ "Notes VARCHAR(200))"; db.execSQL(sqlCMM); //MÙA VỤ sqlCMM="CREATE TABLE SM_REPORT_SALEREP_SEASON(SeasonID VARCHAR(50) PRIMARY KEY,"+ "ReportSaleID VARCHAR(50),"+ "TreeCode VARCHAR(15),"+ "SeasonCode VARCHAR(15),"+ "Title VARCHAR(50)," + "Acreage FLOAT,"+ "Notes VARCHAR(200))"; db.execSQL(sqlCMM); //HOAT ĐỘNG - CÔNG VIỆC - LỊCH CÔNG TÁC: iStYPE: 0 : Công việc, 1: Lịch công tác sqlCMM="CREATE TABLE SM_REPORT_SALEREP_ACTIVITIE(ActivitieID VARCHAR(50) PRIMARY KEY,"+ "ReportSaleID VARCHAR(50),"+ "IsType VARCHAR(15),"+ "Workday VARCHAR(15),"+ "Title VARCHAR(50)," + "Place VARCHAR(100)," + "Notes VARCHAR(200))"; db.execSQL(sqlCMM); // KE HOACH BAN HANG sqlCMM = "CREATE TABLE SM_PLAN_SALE(PlanID VARCHAR(50) PRIMARY KEY," + "PlanCode NVARCHAR(20)," + "PlanDay DATETIME," + "StartDay DATETIME," + "EndDay DATETIME," + "PlanName NVARCHAR(50)," + "PostDay DATETIME," + "IsPost BIT," + "IsStatus INTEGER," + "Notes NVARCHAR(50))"; db.execSQL(sqlCMM); sqlCMM = "CREATE TABLE SM_PLAN_SALE_DETAIL(PlanDetailID VARCHAR(50) PRIMARY KEY," + "PlanID NVARCHAR(50)," + "CustomerID NVARCHAR(50)," + "ProductCode NVARCHAR(20)," + "AmountBox FLOAT," + "Amount FLOAT," + "Notes NVARCHAR(255)," + "Notes2 NVARCHAR(255))"; db.execSQL(sqlCMM); db.execSQL("ALTER TABLE SM_ORDER_DETAIL ADD COLUMN Notes2 VARCHAR(255) DEFAULT ''"); db.execSQL("ALTER TABLE SM_ORDER ADD COLUMN IsSample BIT"); } }catch (Exception ex){ //Toast.makeText(mCxt, "Không thể nâng cấp DB lên V12."+ex.getMessage(), Toast.LENGTH_SHORT).show(); } } public boolean onClearHIS() { try { SQLiteDatabase db = getWritableDatabase(); db.execSQL("DELETE FROM DM_CUSTOMER"); db.execSQL("DELETE FROM DM_PROVINCE"); db.execSQL("DELETE FROM DM_DISTRICT"); db.execSQL("DELETE FROM DM_WARD"); db.execSQL("DELETE FROM DM_PRODUCT"); db.execSQL("DELETE FROM DM_EMPLOYEE"); db.execSQL("DELETE FROM QR_QRSCAN"); db.execSQL("DELETE FROM SM_VISITCARD"); //Toast.makeText(mCxt, "Đã xóa dữ liệu thành công..", Toast.LENGTH_SHORT).show(); return true; }catch (Exception ex){return false;} } public void addTrace(SQLiteDatabase db){ // SQLiteDatabase db=getWritableDatabase(); ContentValues value=new ContentValues(); value.put("id", 1); value.put("trace", 0); db.insert("TRACE", null, value); } //HT_DUNGCHUNG public int getRowCount(String mSql){ try{ SQLiteDatabase db=getReadableDatabase(); Cursor oCurs=db.rawQuery(mSql, null); //Log.d("Cursor_row",oCurs.getString(0)); int iSq= oCurs.getCount(); oCurs.close(); return iSq; }catch (Exception ex){Log.d("RawQuery:",ex.getMessage());} return 0; } //[HT_PARA] public void addHTPara(HT_PARA oHTPara){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("PARA_NAME", oHTPara.getParaCode()); values.put("PARA_VAL", oHTPara.getParaValue()); if (getSizePara(oHTPara.getParaCode())>0){ values.put("PARA_VAL",oHTPara.getParaValue()); db.update("HT_PARA",values,"PARA_NAME" +"=?",new String[] { String.valueOf(oHTPara.getParaCode())}); }else{ db.insert("HT_PARA", null, values); } Log.d("PARA_ADD", oHTPara.getParaValue()); db.close(); }catch (Exception ex){ Log.d("INS_HT_PARA",ex.getMessage().toString());} } public void editHTParam(String ParamName, String ParaVal){ try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("update HT_PARA set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); db.execSQL(mSql); }catch (Exception ex){} } public int getSizePara(String ParaName){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM HT_PARA WHERE PARA_NAME=?", new String[]{ParaName}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public String getParam(String ParamName){ try { SQLiteDatabase db = getReadableDatabase(); String mSql = String.format("select * from HT_PARA where PARA_NAME='%s'", ParamName); Cursor cursor = db.rawQuery(mSql, null); String value=""; if(cursor.moveToFirst()){ value=cursor.getString(cursor.getColumnIndex("PARA_VAL")); } return value; }catch (Exception ex){return "";} } public List<HT_PARA> getAllPara() { List<HT_PARA> lstPara = new ArrayList<HT_PARA>(); String selectQuery = "SELECT * FROM HT_PARA ORDER BY PARA_NAME ASC"; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { HT_PARA oPara = new HT_PARA(); oPara.setParaCode(cursor.getString(0)); oPara.setParaValue(cursor.getString(1)); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } //QR-SCAN public int getSizeQRScan(String QRID,String Customerid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM QR_QRSCAN WHERE Qrid=? AND Customerid=?", new String[]{QRID,Customerid}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public int getQrScanNo(String QRID,String Customerid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT COALESCE(max(ScanNo) ,0) FROM QR_QRSCAN WHERE Qrid=? AND Customerid=?", new String[]{QRID,Customerid}); if (cursor.moveToFirst()) { do { return cursor.getInt(0); } while (cursor.moveToNext()); } cursor.close(); db.close(); }catch(Exception ex){return 0;} return 0; } public boolean addQRScan(QR_QRSCAN oQR){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; //iSq=getSizeQRScan(oQR.getQrid(),oQR.getCustomerid()); iSq=getQrScanNo(oQR.getQrid(),oQR.getCustomerid()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("Qrscanid", oQR.getQrscanid()); values.put("Customerid", oQR.getCustomerid()); values.put("CommandNo", oQR.getCommandNo()); values.put("Qrid", oQR.getQrid()); values.put("ProductCode", oQR.getProductCode()); values.put("ProductName", oQR.getProductName()); values.put("Unit", oQR.getUnit()); values.put("Specification", oQR.getSpecification()); values.put("ScanNo", oQR.getScanNo()); values.put("ScanDay", oQR.getScanDay()); values.put("Longitude", oQR.getLongitude()); values.put("Latitude", oQR.getLatitude()); values.put("LocationAddress", oQR.getLocationAddress()); values.put("ScanSupportID",oQR.getScanSupportID()); values.put("Imei", oQR.getImei()); values.put("ImeiSim", oQR.getImeiSim()); values.put("SyncDay", oQR.getScanDay()); values.put("IsSync", oQR.getSync()); values.put("ScanType",oQR.getScanType()); db.insert("QR_QRSCAN", null, values); }else{ //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); iSq=iSq+1; ContentValues values = new ContentValues(); values.put("CommandNo", oQR.getCommandNo()); values.put("ProductCode", oQR.getProductCode()); values.put("ProductName", oQR.getProductName()); values.put("Unit", oQR.getUnit()); values.put("Specification", oQR.getSpecification()); values.put("ScanNo", iSq); values.put("ScanDay", oQR.getScanDay()); values.put("Longitude", oQR.getLongitude()); values.put("Latitude", oQR.getLatitude()); values.put("LocationAddress", oQR.getLocationAddress()); values.put("ScanSupportID",oQR.getScanSupportID()); values.put("Imei", oQR.getImei()); values.put("ImeiSim", oQR.getImeiSim()); values.put("SyncDay", oQR.getScanDay()); values.put("IsSync", oQR.getSync()); values.put("ScanType",oQR.getScanType()); db.update("QR_QRSCAN",values,"Qrid=? AND Customerid=?" ,new String[] { String.valueOf(oQR.getQrid()),String.valueOf(oQR.getCustomerid())}); } Log.d("INS_QRSCAN_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_QRSCAN_ERR",e.getMessage()); return false;} } public boolean editQRScanStatus(QR_QRSCAN oQR){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("SyncDay", oQR.getScanDay()); values.put("IsSync", oQR.getSync()); db.update("QR_QRSCAN",values,"Qrid=? AND Customerid=?" ,new String[] { String.valueOf(oQR.getQrid()),String.valueOf(oQR.getCustomerid())}); db.close(); return true; }catch (Exception e){Log.v("INS_QRSCAN_ERR",e.getMessage()); return false;} } public boolean delQRScan(QR_QRSCAN oQr){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from QR_QRSCAN where Qrscanid ='%s'",oQr.getQrscanid()); try { db.execSQL(mSql); //Log.d("DEL_QRSCAN",oQr.getQrscanid()); }catch (Exception ex){ Log.d("DEL_QRSCAN",ex.getMessage()); return false; } return true; //db.delete("QR_QRSCAN", "malt = ?", new String[]{malt}); }catch (Exception ex){return false;} } public List<QR_QRSCAN> getAllQRScan(String fDay,String tDay) { List<QR_QRSCAN> lstPara = new ArrayList<QR_QRSCAN>(); String selectQuery =String.format("SELECT A.*,B.CustomerName,C.EmployeeName FROM QR_QRSCAN A LEFT JOIN DM_CUSTOMER B ON A.Customerid=B.Customerid LEFT JOIN DM_EMPLOYEE C ON A.ScanSupportID=C.Employeeid where (julianday(A.ScanDay)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.ScanDay)) >=0 ORDER BY ScanDay desc,ProductCode asc",fDay,tDay); //String selectQuery =String.format("SELECT A.*,B.CustomerName FROM QR_QRSCAN A LEFT JOIN DM_CUSTOMER B ON A.Customerid=B.Customerid ORDER BY ScanDay desc,ProductCode asc"); //Log.d("SQL",selectQuery); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { QR_QRSCAN oPara = new QR_QRSCAN(); oPara.setQrscanid(cursor.getString(cursor.getColumnIndex("Qrscanid"))); oPara.setCustomerid(cursor.getString(cursor.getColumnIndex("Customerid"))); oPara.setCommandNo(cursor.getString(cursor.getColumnIndex("CommandNo"))); oPara.setQrid(cursor.getString(cursor.getColumnIndex("Qrid"))); oPara.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oPara.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); oPara.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); oPara.setSpecification(cursor.getString(cursor.getColumnIndex("Specification"))); oPara.setScanNo(Integer.valueOf(cursor.getString(cursor.getColumnIndex("ScanNo")))); oPara.setScanDay(cursor.getString(cursor.getColumnIndex("ScanDay"))); oPara.setLongitude(Double.valueOf(cursor.getString(cursor.getColumnIndex("Longitude")))); oPara.setLatitude(Double.valueOf(cursor.getString(cursor.getColumnIndex("Latitude")))); oPara.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oPara.setScanSupportID(cursor.getString(cursor.getColumnIndex("ScanSupportID"))); oPara.setScanSupportDesc(cursor.getString(cursor.getColumnIndex("EmployeeName"))); oPara.setImei(cursor.getString(cursor.getColumnIndex("Imei"))); oPara.setImeiSim(cursor.getString(cursor.getColumnIndex("ImeiSim"))); oPara.setSyncDay(cursor.getString(cursor.getColumnIndex("SyncDay"))); if(cursor.getString(cursor.getColumnIndex("IsSync")).contains("1")){ oPara.setSync(true); }else{ oPara.setSync(false); } oPara.setScanType(cursor.getString(cursor.getColumnIndex("ScanType"))); oPara.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public List<QR_QRSCAN> getQRScan(String QrID,String CustomerID) { List<QR_QRSCAN> lstPara = new ArrayList<QR_QRSCAN>(); String selectQuery = "SELECT * FROM QR_QRSCAN where Qrid=? and Customerid=? ORDER BY ScanDay desc,ProductCode asc"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, new String[]{QrID,CustomerID}); if (cursor.moveToFirst()) { do { QR_QRSCAN oPara = new QR_QRSCAN(); oPara.setQrscanid(cursor.getString(cursor.getColumnIndex("Qrscanid"))); oPara.setCustomerid(cursor.getString(cursor.getColumnIndex("Customerid"))); oPara.setCommandNo(cursor.getString(cursor.getColumnIndex("CommandNo"))); oPara.setQrid(cursor.getString(cursor.getColumnIndex("Qrid"))); oPara.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oPara.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); oPara.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); oPara.setSpecification(cursor.getString(cursor.getColumnIndex("Specification"))); oPara.setScanNo(Integer.valueOf(cursor.getString(cursor.getColumnIndex("ScanNo")))); oPara.setScanDay(cursor.getString(cursor.getColumnIndex("ScanDay"))); oPara.setLongitude(Double.valueOf(cursor.getString(cursor.getColumnIndex("Longitude")))); oPara.setLatitude(Double.valueOf(cursor.getString(cursor.getColumnIndex("Latitude")))); oPara.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oPara.setScanSupportID(cursor.getString(cursor.getColumnIndex("ScanSupportID"))); oPara.setScanSupportDesc(cursor.getString(cursor.getColumnIndex("EmployeeName"))); oPara.setImei(cursor.getString(cursor.getColumnIndex("Imei"))); oPara.setImeiSim(cursor.getString(cursor.getColumnIndex("ImeiSim"))); oPara.setSyncDay(cursor.getString(cursor.getColumnIndex("SyncDay"))); if(cursor.getString(cursor.getColumnIndex("IsSync")).contains("1")){ oPara.setSync(true); }else{ oPara.setSync(false); } oPara.setScanType(cursor.getString(cursor.getColumnIndex("ScanType"))); //oPara.setSync(Boolean.parseBoolean(cursor.getString(cursor.getColumnIndex("IsSync")))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } //DM_PRODUCT public int getSizeProduct(String ProductCode){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_PRODUCT WHERE ProductCode=?",new String[]{ProductCode}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addProduct(DM_Product oPro){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeProduct(oPro.getProductCode().toString()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("ProductCode",oPro.getProductCode()); values.put("ProductName", oPro.getProductName()); values.put("Unit",oPro.getUnit()); values.put("Spec", oPro.getSpecification()); values.put("ConvertKgl", oPro.getConvertKgl()); values.put("ConvertBox", oPro.getConvertBox()); values.put("isMain", oPro.getMain()); db.insert("DM_PRODUCT", null, values); }else{ //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); iSq=iSq+1; ContentValues values = new ContentValues(); values.put("ProductName", oPro.getProductName()); values.put("Unit",oPro.getUnit()); values.put("Spec", oPro.getSpecification()); values.put("ConvertKgl", oPro.getConvertKgl()); values.put("ConvertBox", oPro.getConvertBox()); values.put("isMain", oPro.getMain()); db.update("DM_PRODUCT",values,"ProductCode=?" ,new String[] { String.valueOf(oPro.getProductCode())}); } //Log.d("INS_PRODUCT_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_PRODUCT_ERR",e.getMessage()); return false;} } public List<DM_Product> getAllProduct() { List<DM_Product> lstPara = new ArrayList<DM_Product>(); String selectQuery = "SELECT ProductCode,ProductGroupID,ProductName,Unit," + "Spec,ConvertKgl,ConvertBox,isMain FROM DM_PRODUCT ORDER BY ProductCode ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Product oPara = new DM_Product(); oPara.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oPara.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); oPara.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); oPara.setSpecification(cursor.getString(cursor.getColumnIndex("Spec"))); oPara.setConvertKgl(cursor.getFloat(cursor.getColumnIndex("ConvertKgl"))); oPara.setConvertBox(cursor.getFloat(cursor.getColumnIndex("ConvertBox"))); oPara.setMain(Boolean.getBoolean(cursor.getString(cursor.getColumnIndex("isMain")))); lstPara.add(oPara); }while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public DM_Product getProduct(String mProductCode) { List<DM_Product> lstPara = new ArrayList<DM_Product>(); String selectQuery = "SELECT ProductCode,ProductGroupID,ProductName,Unit," + "Spec,ConvertKgl,ConvertBox,isMain FROM DM_PRODUCT WHERE ProductCode=? ORDER BY ProductCode ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, new String[]{mProductCode}); DM_Product oPara = new DM_Product(); if (cursor.moveToFirst()) { do { oPara.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oPara.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); oPara.setSpecification(cursor.getString(cursor.getColumnIndex("Spec"))); oPara.setConvertKgl(cursor.getFloat(cursor.getColumnIndex("ConvertKgl"))); oPara.setConvertBox(cursor.getFloat(cursor.getColumnIndex("ConvertBox"))); oPara.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); oPara.setMain(Boolean.getBoolean(cursor.getString(cursor.getColumnIndex("isMain")))); cursor.close(); db.close(); return oPara; } while (cursor.moveToNext()); } cursor.close(); db.close(); return null ; } public boolean delProduct(String ProductCode,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_PRODUCT"); }else{ mSql = String.format("delete from DM_PRODUCT where ProductCode='%s'", ProductCode); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } //DM_PROVINCE public int getSizeProvince(String Provinceid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_PROVINCE WHERE Provinceid=?",new String[]{Provinceid}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addProvince(DM_Province oPro){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeProvince(oPro.getProvinceid().toString()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("Provinceid",oPro.getProvinceid()); values.put("ProvinceCode", oPro.getProvinceCode()); values.put("Province",oPro.getProvince()); values.put("ZoneCode", oPro.getZoneCode()); db.insert("DM_PROVINCE", null, values); }else{ //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); iSq=iSq+1; ContentValues values = new ContentValues(); values.put("ProvinceCode", oPro.getProvinceCode()); values.put("Province",oPro.getProvince()); values.put("ZoneCode", oPro.getZoneCode()); db.update("DM_PROVINCE",values,"Provinceid=?" ,new String[] { String.valueOf(oPro.getProvinceid().toString())}); } //Log.d("INS_PROVINCE_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_DISTRICT_ERR",e.getMessage()); return false;} } public List<DM_Province> getAllProvince() { List<DM_Province> lstPara = new ArrayList<DM_Province>(); String selectQuery = "SELECT * FROM DM_PROVINCE ORDER BY Province ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Province oPara = new DM_Province(); oPara.setProvinceid(cursor.getInt(0)); oPara.setProvinceCode(cursor.getString(1)); oPara.setProvince(cursor.getString(2)); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public boolean delProvince(String Provinceid,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_PROVINCE"); }else{ mSql = String.format("delete from DM_PROVINCE where Provinceid='%s'", Provinceid); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } //DM_DISTRICT public int getSizeDistrict(String Districtid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_DISTRICT WHERE Districtid=?",new String[]{Districtid}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addDistrict(DM_District oPro){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeDistrict(Integer.toString(oPro.getDistrictid())); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("Districtid",oPro.getDistrictid()); values.put("Provinceid",oPro.getProvinceid()); values.put("District", oPro.getDistrict()); db.insert("DM_DISTRICT", null, values); }else{ iSq=iSq+1; ContentValues values = new ContentValues(); values.put("District", oPro.getDistrict()); values.put("Provinceid",oPro.getProvinceid()); db.update("DM_DISTRICT",values,"Districtid=?" ,new String[] { String.valueOf(oPro.getDistrictid())}); } //Log.d("INS_DISTRICT_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_DISTRICT_ERR",e.getMessage()); return false;} } public List<DM_District> getAllDistrict() { List<DM_District> lstPara = new ArrayList<DM_District>(); String selectQuery = "SELECT A.Districtid,A.Provinceid,A.District,B.Province FROM DM_DISTRICT A LEFT JOIN DM_PROVINCE B ON A.Provinceid=b.Provinceid ORDER BY District ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_District oPara = new DM_District(); oPara.setDistrictid(cursor.getInt(cursor.getColumnIndex("Districtid"))); oPara.setProvinceid(cursor.getInt(cursor.getColumnIndex("Provinceid"))); oPara.setDistrict(cursor.getString(cursor.getColumnIndex("District"))); oPara.setProvince(cursor.getString(cursor.getColumnIndex("Province"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public List<DM_District> getDistrict(Integer Provinceid) { List<DM_District> lstPara = new ArrayList<DM_District>(); String selectQuery = String.format("SELECT A.Districtid,A.Provinceid,A.District,B.Province FROM DM_DISTRICT A LEFT JOIN DM_PROVINCE B ON A.Provinceid=b.Provinceid where A.Provinceid='%d' ORDER BY District ASC",Provinceid); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); //Log.d("SQL_SEL_DISTRICT",selectQuery); if (cursor.moveToFirst()) { do { DM_District oPara = new DM_District(); oPara.setDistrictid(cursor.getInt(cursor.getColumnIndex("Districtid"))); oPara.setProvinceid(cursor.getInt(cursor.getColumnIndex("Provinceid"))); oPara.setDistrict(cursor.getString(cursor.getColumnIndex("District"))); oPara.setProvince(cursor.getString(cursor.getColumnIndex("Province"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public boolean delDistrict(String Districtid,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_DISTRICT"); }else{ mSql = String.format("delete from DM_DISTRICT where Districtid='%s'", Districtid); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } //DM_WARD public int getSizeWard(String Wardid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_WARD WHERE Wardid=?",new String[]{Wardid}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addWard(DM_Ward oPro){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeWard(Integer.toString(oPro.getWardid())); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("Wardid",oPro.getWardid()); values.put("Districtid",oPro.getDistrictid()); values.put("Ward", oPro.getWard()); db.insert("DM_WARD", null, values); }else{ iSq=iSq+1; ContentValues values = new ContentValues(); values.put("Ward", oPro.getWard()); values.put("Wardid",oPro.getWardid()); db.update("DM_WARD",values,"Wardid=?" ,new String[] { String.valueOf(oPro.getWardid())}); } //Log.d("INS_WARD_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_WARD_ERR",e.getMessage()); return false;} } public List<DM_Ward> getAllWard() { List<DM_Ward> lstPara = new ArrayList<DM_Ward>(); String selectQuery = "SELECT A.*,B.District FROM DM_WARD A LEFT JOIN DM_DISTRICT B ON A.Districtid=b.Districtid ORDER BY Ward ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Ward oPara = new DM_Ward(); oPara.setWardid(cursor.getInt(0)); oPara.setDistrictid(cursor.getInt(1)); oPara.setWard(cursor.getString(2)); oPara.setDistrict(cursor.getString(4)); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public List<DM_Ward> getWard(Integer Districtid) { List<DM_Ward> lstPara = new ArrayList<DM_Ward>(); String selectQuery =String.format("SELECT A.*,B.District FROM DM_WARD A LEFT JOIN DM_DISTRICT B ON A.Districtid=b.Districtid where A.Districtid='%d' ORDER BY Ward ASC",Districtid); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Ward oPara = new DM_Ward(); oPara.setWardid(cursor.getInt(0)); oPara.setDistrictid(cursor.getInt(1)); oPara.setWard(cursor.getString(2)); oPara.setDistrict(cursor.getString(4)); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public boolean delWard(String Wardid,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_WARD"); }else{ mSql = String.format("delete from DM_WARD where Wardid='%s'", Wardid); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } //CUSTOMER public int getSizeCustomerPenddingAprrove(){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT Customerid FROM DM_CUSTOMER WHERE EditStatus =? OR EditStatus=?",new String[]{"4","6"}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public int getSizeCustomer(String CustomerID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_CUSTOMER WHERE Customerid=?", new String[]{CustomerID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public DM_Customer getCustomer(String CustomerID) { try { DM_Customer oCus = new DM_Customer(); String selectQuery = "SELECT A.Customerid,A.Employeeid,A.CustomerCode,A.CustomerName," + " A.ShortName,A.Represent,A.Provinceid,A.Districtid,A.Wardid,A.Street,A.Tel,A.Tax,A.Fax,A.Email," + " A.Longitude,A.Latitude,A.LongitudeTemp,A.LatitudeTemp,A.LocationAddressTemp,A.EditStatus,A.Notes,A.Ranked, " + " B.Province,C.District,D.Ward " + " FROM DM_CUSTOMER A LEFT JOIN DM_PROVINCE B ON A.Provinceid=b.Provinceid " + " LEFT JOIN DM_DISTRICT C ON A.Districtid=C.Districtid "+ " LEFT JOIN DM_WARD D ON A.Wardid=D.Wardid "+ " WHERE A.Customerid=? ORDER BY Customerid ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, new String[]{CustomerID}); if (cursor.moveToFirst()) { do { oCus.setCustomerid(cursor.getString(cursor.getColumnIndex("Customerid"))); oCus.setEmployeeid(cursor.getString(cursor.getColumnIndex("Employeeid"))); oCus.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oCus.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oCus.setShortName(cursor.getString(cursor.getColumnIndex("ShortName"))); oCus.setRepresent(cursor.getString(cursor.getColumnIndex("Represent"))); oCus.setProvinceid(cursor.getInt(cursor.getColumnIndex("Provinceid"))); oCus.setDistrictid(cursor.getInt(cursor.getColumnIndex("Districtid"))); oCus.setWardid(cursor.getInt(cursor.getColumnIndex("Wardid"))); oCus.setStreet(cursor.getString(cursor.getColumnIndex("Street"))); oCus.setTel(cursor.getString(cursor.getColumnIndex("Tel"))); oCus.setTax(cursor.getString(cursor.getColumnIndex("Tax"))); oCus.setFax(cursor.getString(cursor.getColumnIndex("Fax"))); oCus.setEmail(cursor.getString(cursor.getColumnIndex("Email"))); oCus.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oCus.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oCus.setLongitudeTemp(cursor.getDouble(cursor.getColumnIndex("LongitudeTemp"))); oCus.setLatitudeTemp(cursor.getDouble(cursor.getColumnIndex("LatitudeTemp"))); oCus.setLocationAddressTemp(cursor.getString(cursor.getColumnIndex("LocationAddressTemp"))); oCus.setEdit(cursor.getInt(cursor.getColumnIndex("EditStatus"))); if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==1){ oCus.setStatusDesc("Mới"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==2){ oCus.setStatusDesc("Sửa"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==3){ oCus.setStatusDesc("Xóa"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==4){ oCus.setStatusDesc("Chờ duyệt"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==5){ oCus.setStatusDesc("Từ chối"); }else{ oCus.setStatusDesc(""); } oCus.setProvinceName(cursor.getString(cursor.getColumnIndex("Province"))); oCus.setDistrictName(cursor.getString(cursor.getColumnIndex("District"))); oCus.setWardName(cursor.getString(cursor.getColumnIndex("Ward"))); oCus.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oCus.setRanked(cursor.getString(cursor.getColumnIndex("Ranked"))); return oCus; } while (cursor.moveToNext()); } cursor.close(); db.close(); return oCus; }catch (Exception ex){Log.d("ERR_LOAD_CUS",ex.getMessage().toString());} return null; } public List<DM_Customer> getAllCustomer() { try { List<DM_Customer> lstPara = new ArrayList<DM_Customer>(); String selectQuery = "SELECT A.Customerid,A.Employeeid,A.CustomerCode,A.CustomerName," + " A.ShortName,A.Represent,A.Provinceid,A.Districtid,A.Wardid,A.Street,A.Tel,A.Tax,A.Fax,A.Email," + " A.Longitude,A.Latitude,A.LongitudeTemp,A.LatitudeTemp,A.LocationAddress,A.LocationAddressTemp,A.EditStatus,A.Notes,A.Ranked, " + " B.Province,C.District,D.Ward " + " FROM DM_CUSTOMER A LEFT JOIN DM_PROVINCE B ON A.Provinceid=b.Provinceid " + " LEFT JOIN DM_DISTRICT C ON A.Districtid=C.Districtid "+ " LEFT JOIN DM_WARD D ON A.Wardid=D.Wardid "+ " ORDER BY A.EditStatus desc, Customerid ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Customer oCus = new DM_Customer(); oCus.setCustomerid(cursor.getString(cursor.getColumnIndex("Customerid"))); oCus.setEmployeeid(cursor.getString(cursor.getColumnIndex("Employeeid"))); oCus.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oCus.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oCus.setShortName(cursor.getString(cursor.getColumnIndex("ShortName"))); oCus.setRepresent(cursor.getString(cursor.getColumnIndex("Represent"))); oCus.setProvinceid(cursor.getInt(cursor.getColumnIndex("Provinceid"))); oCus.setDistrictid(cursor.getInt(cursor.getColumnIndex("Districtid"))); oCus.setWardid(cursor.getInt(cursor.getColumnIndex("Wardid"))); oCus.setStreet(cursor.getString(cursor.getColumnIndex("Street"))); oCus.setTax(cursor.getString(cursor.getColumnIndex("Tax"))); oCus.setTel(cursor.getString(cursor.getColumnIndex("Tel"))); oCus.setFax(cursor.getString(cursor.getColumnIndex("Fax"))); oCus.setEmail(cursor.getString(cursor.getColumnIndex("Email"))); oCus.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oCus.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oCus.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); if(cursor.getDouble(cursor.getColumnIndex("LongitudeTemp"))<=0){ oCus.setLongitudeTemp(cursor.getDouble(cursor.getColumnIndex("Longitude"))); }else{ oCus.setLongitudeTemp(cursor.getDouble(cursor.getColumnIndex("LongitudeTemp"))); } if(cursor.getDouble(cursor.getColumnIndex("LatitudeTemp"))<=0) { oCus.setLatitudeTemp(cursor.getDouble(cursor.getColumnIndex("Latitude"))); }else{ oCus.setLatitudeTemp(cursor.getDouble(cursor.getColumnIndex("LatitudeTemp"))); } oCus.setLocationAddressTemp(cursor.getString(cursor.getColumnIndex("LocationAddressTemp"))); oCus.setEdit(cursor.getInt(cursor.getColumnIndex("EditStatus"))); if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==1){ oCus.setStatusDesc("Mới"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==2){ oCus.setStatusDesc("Sửa"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==3){ oCus.setStatusDesc("Xóa"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==4){ oCus.setStatusDesc("Chờ duyệt"); }else if(cursor.getInt(cursor.getColumnIndex("EditStatus"))==5){ oCus.setStatusDesc("Từ chối"); }else{ oCus.setStatusDesc(""); } oCus.setProvinceName(cursor.getString(cursor.getColumnIndex("Province"))); oCus.setDistrictName(cursor.getString(cursor.getColumnIndex("District"))); oCus.setWardName(cursor.getString(cursor.getColumnIndex("Ward"))); oCus.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oCus.setRanked(cursor.getString(cursor.getColumnIndex("Ranked"))); lstPara.add(oCus); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; }catch (Exception ex){Log.d("ERR_LOAD_CUS",ex.getMessage().toString());} return null; } public List<DM_Customer_Search> getAllCustomerSearch() { try { List<DM_Customer_Search> lstPara = new ArrayList<DM_Customer_Search>(); String selectQuery = "SELECT A.Customerid,A.CustomerCode,A.CustomerName," + " A.ShortName,A.Represent,B.Province,A.Longitude,A.Latitude" + " FROM DM_CUSTOMER A LEFT JOIN DM_PROVINCE B ON A.Provinceid=b.Provinceid " + " ORDER BY A.EditStatus desc, Customerid ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Customer_Search oCus = new DM_Customer_Search(); oCus.setCustomerid(cursor.getString(cursor.getColumnIndex("Customerid"))); oCus.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oCus.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oCus.setShortName(cursor.getString(cursor.getColumnIndex("ShortName"))); oCus.setLongititude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oCus.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oCus.setProvinceName(cursor.getString(cursor.getColumnIndex("Province"))); lstPara.add(oCus); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; }catch (Exception ex){Log.d("ERR_LOAD_CUS",ex.getMessage().toString());} return null; } public boolean addCustomer(DM_Customer oCus){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeCustomer(oCus.getCustomerid()); if (iSq<0) { //Log.d("INS_CUSTOMER_DB","ERROR :-1"); db.close(); //return false; } if (iSq<=0 && iSq!=-1) { ContentValues values = new ContentValues(); values.put("Customerid", oCus.getCustomerid()); values.put("Employeeid", oCus.getEmployeeid()); values.put("CustomerCode", oCus.getCustomerCode()); values.put("CustomerName",oCus.getCustomerName()); values.put("ShortName", oCus.getShortName()); values.put("Represent", oCus.getRepresent()); values.put("Provinceid", oCus.getProvinceid()); values.put("Districtid", oCus.getDistrictid()); values.put("Wardid",oCus.getWardid()); values.put("Street", oCus.getStreet()); values.put("Address", oCus.getAddress()); values.put("Tax", oCus.getTax()); values.put("Tel", oCus.getTel()); values.put("Fax", oCus.getFax()); values.put("Email",oCus.getEmail()); values.put("Longitude", oCus.getLongitude()); values.put("Latitude", oCus.getLatitude()); values.put("LocationAddress",oCus.getLocationAddress()); values.put("Notes", oCus.getNotes()); values.put("EditStatus", oCus.getEdit()); values.put("Ranked",oCus.getRanked()); db.insert("DM_CUSTOMER", null, values); }else{ //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); ContentValues values = new ContentValues(); values.put("Employeeid", oCus.getEmployeeid()); values.put("CustomerCode", oCus.getCustomerCode()); values.put("CustomerName",oCus.getCustomerName()); values.put("ShortName", oCus.getShortName()); values.put("Represent", oCus.getRepresent()); values.put("Provinceid", oCus.getProvinceid()); values.put("Districtid", oCus.getDistrictid()); values.put("Wardid",oCus.getWardid()); values.put("Street", oCus.getStreet()); values.put("Address", oCus.getAddress()); values.put("Tel", oCus.getTel()); values.put("Tax", oCus.getTax()); values.put("Fax", oCus.getFax()); values.put("Email",oCus.getEmail()); values.put("Longitude", oCus.getLongitude()); values.put("Latitude", oCus.getLatitude()); values.put("LocationAddress",oCus.getLocationAddress()); values.put("Notes", oCus.getNotes()); values.put("EditStatus", oCus.getEdit()); values.put("Ranked",oCus.getRanked()); db.update("DM_CUSTOMER",values,"Customerid=?" ,new String[] {String.valueOf(oCus.getCustomerid())}); } //Log.d("INS_CUSTOMER_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_CUSTOMER_ERR",e.getMessage()); return false;} } public String addCustomer2(DM_Customer oCus) { try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq = getSizeCustomer(oCus.getCustomerid()); if (iSq < 0) { db.close(); //return false; } if (iSq <= 0 && iSq != -1) { ContentValues values = new ContentValues(); values.put("Customerid", oCus.getCustomerid()); values.put("Employeeid", oCus.getEmployeeid()); values.put("CustomerCode", oCus.getCustomerCode()); values.put("CustomerName", oCus.getCustomerName()); values.put("ShortName", oCus.getShortName()); values.put("Represent", oCus.getRepresent()); values.put("Provinceid", oCus.getProvinceid()); values.put("Districtid", oCus.getDistrictid()); values.put("Wardid", oCus.getWardid()); values.put("Street", oCus.getStreet()); values.put("Address", oCus.getAddress()); values.put("Tel", oCus.getTel()); values.put("Tax", oCus.getTax()); values.put("Fax", oCus.getFax()); values.put("Email", oCus.getEmail()); values.put("Longitude", 0); values.put("Latitude", 0); values.put("LocationAddress", ""); values.put("LongitudeTemp", oCus.getLongitudeTemp()); values.put("LatitudeTemp", oCus.getLatitudeTemp()); values.put("LocationAddressTemp",oCus.getLocationAddressTemp()); values.put("Notes", oCus.getNotes()); values.put("EditStatus", oCus.getEdit()); db.insert("DM_CUSTOMER", null, values); } return "OK"; }catch (Exception ex){ return ex.getMessage(); } } public boolean editCustomer(DM_Customer oCus){ try { SQLiteDatabase db = this.getWritableDatabase(); //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); ContentValues values = new ContentValues(); values.put("Employeeid", oCus.getEmployeeid()); values.put("CustomerCode", oCus.getCustomerCode()); values.put("CustomerName",oCus.getCustomerName()); values.put("ShortName", oCus.getShortName()); values.put("Represent", oCus.getRepresent()); values.put("Provinceid", oCus.getProvinceid()); values.put("Districtid", oCus.getDistrictid()); values.put("Wardid",oCus.getWardid()); values.put("Street", oCus.getStreet()); values.put("Address", oCus.getAddress()); values.put("Tel", oCus.getTel()); values.put("Tax", oCus.getTax()); values.put("Fax", oCus.getFax()); values.put("Email",oCus.getEmail()); values.put("LongitudeTemp", oCus.getLongitudeTemp()); values.put("LatitudeTemp", oCus.getLatitudeTemp()); values.put("LocationAddressTemp",oCus.getLocationAddressTemp()); values.put("Notes", oCus.getNotes()); values.put("EditStatus", oCus.getEdit()); db.update("DM_CUSTOMER",values,"Customerid=?" ,new String[] {String.valueOf(oCus.getCustomerid())}); //Log.d("UDP_CUSTOMER_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("UDP_CUSTOMER_ERR",e.getMessage()); return false;} } public boolean delCustomer(String CustomerID,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_CUSTOMER"); }else{ mSql = String.format("delete from DM_CUSTOMER where Customerid='%s'", CustomerID); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } //CUSTOMER_DISTANCE public List<DM_Customer_Distance> getAllCustomerDistance() { try { List<DM_Customer_Distance> lstPara = new ArrayList<DM_Customer_Distance>(); String selectQuery = "SELECT distinct Customerid,CustomerName,Longitude,Latitude from DM_CUSTOMER WHERE Longitude>0 AND Latitude>0 "; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Customer_Distance oCus = new DM_Customer_Distance(); oCus.setCustomerid(cursor.getString(cursor.getColumnIndex("Customerid"))); oCus.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oCus.setLongititude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oCus.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oCus.setDistance(Float.valueOf(0)); lstPara.add(oCus); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; }catch (Exception ex){Log.d("ERR_LOAD_CUS",ex.getMessage().toString());} return null; } //DM_EMPLOYEE public int getSizeEmployee(String Employeeid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_EMPLOYEE WHERE Employeeid=?",new String[]{Employeeid}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addEmployee(DM_Employee oEmp){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeEmployee(oEmp.getEmployeeid().toString()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("Employeeid",oEmp.getEmployeeid()); values.put("EmployeeCode",oEmp.getEmployeeCode()); values.put("EmployeeName",oEmp.getEmployeeName()); values.put("Notes", oEmp.getNotes()); db.insert("DM_EMPLOYEE", null, values); }else{ //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); iSq=iSq+1; ContentValues values = new ContentValues(); values.put("EmployeeCode",oEmp.getEmployeeCode()); values.put("EmployeeName",oEmp.getEmployeeName()); values.put("Notes", oEmp.getNotes()); db.update("DM_EMPLOYEE",values,"Employeeid=?" ,new String[] { String.valueOf(oEmp.getEmployeeid().toString())}); } //Log.d("INS_PROVINCE_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("INS_DM_EMPLOYEE_ERR",e.getMessage()); return false;} } public List<DM_Employee> getAllEmployee() { List<DM_Employee> lstPara = new ArrayList<DM_Employee>(); String selectQuery = "SELECT * FROM DM_EMPLOYEE ORDER BY EmployeeName ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Employee oPara = new DM_Employee(); oPara.setEmployeeid(cursor.getString(cursor.getColumnIndex("Employeeid"))); oPara.setEmployeeCode(cursor.getString(cursor.getColumnIndex("EmployeeCode"))); oPara.setEmployeeName(cursor.getString(cursor.getColumnIndex("EmployeeName"))); oPara.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public boolean delEmployee(String Employeeid,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_EMPLOYEE"); }else{ mSql = String.format("delete from DM_EMPLOYEE where Employeeid='%s'", Employeeid); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } //SMVISIT-CARD private String getVisitCardid(String VisitDay,String mCustomerID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_VISITCARD WHERE (julianday(VisitDay)-julianday('%s')=0) and CustomerID='%s' ", new String[]{VisitDay,mCustomerID}); String VisitCardID=""; if (cursor.moveToFirst()) { do { VisitCardID=cursor.getString(cursor.getColumnIndex("VisitCardID")); break; } while (cursor.moveToNext()); } cursor.close(); return VisitCardID; }catch(Exception ex){return "";} } public int getSizeVisitCard(String VisitCardID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_VISITCARD WHERE VisitCardID=?", new String[]{VisitCardID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanVisitCard(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_VISITCARD where julianday('now')-julianday(VisitDay)>%s", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } //Fortmat yy public List<SM_VisitCard> getAllVisitCard(String fday,String tDay) { try { List<SM_VisitCard> lstVisit = new ArrayList<SM_VisitCard>(); String mSql=String.format("Select A.*,B.CustomerName from SM_VISITCARD A LEFT JOIN DM_CUSTOMER B on ifnull(a.CustomerID,'')=b.Customerid "+ " where (julianday(A.VisitDay)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.VisitDay)) >=0 order by VisitDay desc,VisitTime desc",fday,tDay); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_VisitCard oVisitCard = new SM_VisitCard(); oVisitCard.setVisitCardID(cursor.getString(cursor.getColumnIndex("VisitCardID"))); oVisitCard.setVisitDay(cursor.getString(cursor.getColumnIndex("VisitDay"))); oVisitCard.setVisitType(cursor.getString(cursor.getColumnIndex("VisitType"))); oVisitCard.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oVisitCard.setCustomerID(cursor.getString(cursor.getColumnIndex("CustomerID"))); oVisitCard.setVisitTime(cursor.getString(cursor.getColumnIndex("VisitTime"))); oVisitCard.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oVisitCard.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oVisitCard.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oVisitCard.setVisitNotes(cursor.getString(cursor.getColumnIndex("VisitNotes"))); oVisitCard.setSyncDay(cursor.getString(cursor.getColumnIndex("SyncDay"))); if(cursor.getString(cursor.getColumnIndex("IsSync")).contains("1")){ oVisitCard.setSync(true); }else{ oVisitCard.setSync(false); } lstVisit.add(oVisitCard); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstVisit; }catch (Exception ex){Log.d("ERR_LOAD_SM_VISIT",ex.getMessage().toString());} return null; } public SM_VisitCard getVisitCard(String VisitCardID) { try { String mSql=String.format("Select A.*,B.CustomerName from SM_VISITCARD A LEFT JOIN DM_CUSTOMER B on a.CustomerID=b.Customerid "+ " where A.VisitCardID='%s' order by VisitDay desc",VisitCardID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_VisitCard oVisitCard = new SM_VisitCard(); if (cursor.moveToFirst()) { do { oVisitCard.setVisitCardID(cursor.getString(cursor.getColumnIndex("VisitCardID"))); oVisitCard.setVisitDay(cursor.getString(cursor.getColumnIndex("VisitDay"))); oVisitCard.setVisitType(cursor.getString(cursor.getColumnIndex("VisitType"))); oVisitCard.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oVisitCard.setCustomerID(cursor.getString(cursor.getColumnIndex("CustomerID"))); oVisitCard.setVisitTime(cursor.getString(cursor.getColumnIndex("VisitTime"))); oVisitCard.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oVisitCard.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oVisitCard.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oVisitCard.setVisitNotes(cursor.getString(cursor.getColumnIndex("VisitNotes"))); oVisitCard.setSyncDay(cursor.getString(cursor.getColumnIndex("SyncDay"))); if(cursor.getString(cursor.getColumnIndex("IsSync")).contains("1")){ oVisitCard.setSync(true); }else{ oVisitCard.setSync(false); } break; } while (cursor.moveToNext()); } cursor.close(); db.close(); return oVisitCard; }catch (Exception ex){Log.d("ERR_LOAD_SM_VISIT",ex.getMessage().toString());} return null; } public String addVisitCard(SM_VisitCard oVisit){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String VisitCardID=getVisitCardid(oVisit.getVisitDay(),oVisit.getCustomerID()); if(VisitCardID!=""){ if(oVisit.getVisitCardID().isEmpty()|| oVisit.getVisitCardID()==null){ oVisit.setVisitCardID(VisitCardID); } } iSq=getSizeVisitCard(oVisit.getVisitCardID()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("VisitCardID", oVisit.getVisitCardID()); values.put("VisitDay", oVisit.getVisitDay()); values.put("VisitType", oVisit.getVisitType()); values.put("CustomerID", oVisit.getCustomerID()); values.put("VisitTime", oVisit.getVisitTime()); values.put("Longitude",oVisit.getLongitude()); values.put("Latitude", oVisit.getLatitude()); values.put("LocationAddress", oVisit.getLocationAddress()); values.put("VisitNotes", oVisit.getVisitNotes()); values.put("IsSync", oVisit.getSync()); db.insert("SM_VISITCARD", null, values); }else{ ContentValues values = new ContentValues(); values.put("VisitDay", oVisit.getVisitDay()); values.put("CustomerID", oVisit.getCustomerID()); values.put("VisitTime", oVisit.getVisitTime()); values.put("Longitude",oVisit.getLongitude()); values.put("Latitude", oVisit.getLatitude()); values.put("LocationAddress", oVisit.getLocationAddress()); values.put("VisitNotes", oVisit.getVisitNotes()); values.put("IsSync", oVisit.getSync()); db.update("SM_VISITCARD",values,"VisitCardID=?" ,new String[] {String.valueOf(oVisit.getVisitCardID())}); } //Log.d("INS_VISITCARD_DB","OK"); db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean editVisitCard(SM_VisitCard oVisit){ try { SQLiteDatabase db = this.getWritableDatabase(); //String mSql = String.format("update QR_QRSCAN set PARA_VAL='%s' where PARA_NAME='%s'", ParamName, ParaVal); //db.execSQL(mSql); ContentValues values = new ContentValues(); values.put("IsSync", oVisit.getSync()); values.put("SyncDay",oVisit.getSyncDay()); db.update("SM_VISITCARD",values,"VisitCardID=?" ,new String[] {String.valueOf(oVisit.getVisitCardID())}); //Log.d("UDP_SM_VISITCARD_DB","OK"); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_VISITCARD_ERR",e.getMessage()); return false;} } public boolean delVisitCard(SM_VisitCard oVisit){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from SM_VISITCARD where VisitCardID='%s'",oVisit.getVisitCardID()); try { db.execSQL(mSql); //Log.d("DEL_VISIT_CARD",oVisit.getVisitCardID()); }catch (Exception ex){ //Log.d("DEL_VISIT_CARD",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } /********************/ /*<<SM-ORDER>>*/ /********************/ public boolean getCheckOrderStatus(String mToday){ try { SQLiteDatabase db = getReadableDatabase(); //Cursor cursor = db.rawQuery("SELECT * FROM SM_ORDER WHERE OrderStatus<=3 and (julianday('%s')-julianday(OrderDate)>=7)", new String[]{mToday}); Cursor cursor = db.rawQuery("SELECT * FROM SM_ORDER WHERE OrderStatus<=3",null); int iSq= cursor.getCount(); cursor.close(); if (iSq>0){return true;}else{return false;} }catch(Exception ex){return false;} } private String getSMOrderID(String OrderDay,String mCustomerID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_ORDER WHERE (julianday(OrderDate)-julianday('%s')=0) and CustomerID='%s' ", new String[]{OrderDay,mCustomerID}); String OrderID=""; if (cursor.moveToFirst()) { do { OrderID=cursor.getString(cursor.getColumnIndex("OrderID")); break; } while (cursor.moveToNext()); } cursor.close(); return OrderID; }catch(Exception ex){return "";} } public int getSizeSMOrder(String OrderID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_ORDER WHERE OrderID=?", new String[]{OrderID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanSMOrder(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_ORDER_DETAIL where OrderID in(select OrderID from SM_ORDER where julianday('now')-julianday(OrderDate)>%s)", iIntervalDay); db.execSQL(mSql); mSql = String.format("delete from SM_ORDER where julianday('now')-julianday(OrderDate)>%s", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } //Fortmat yy public List<SM_Order> getAllSMOrder(String fday,String tDay) { try { List<SM_Order> lstOrder = new ArrayList<SM_Order>(); String mSql=String.format("Select A.*,B.CustomerName,B.CustomerCode,B.LocationAddress as CustomerAddress from SM_ORDER A LEFT JOIN DM_CUSTOMER B on ifnull(a.CustomerID,'')=b.Customerid "+ " where (julianday(A.OrderDate)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.OrderDate)) >=0 order by OrderDate desc,RequestDate desc",fday,tDay); //Log.d("SQL_ORDER",mSql); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_Order oOrder = new SM_Order(); oOrder.setOrderID(cursor.getString(cursor.getColumnIndex("OrderID"))); oOrder.setOrderCode(cursor.getString(cursor.getColumnIndex("OrderCode"))); oOrder.setCustomerID(cursor.getString(cursor.getColumnIndex("CustomerID"))); oOrder.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oOrder.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oOrder.setCustomerAddress(cursor.getString(cursor.getColumnIndex("CustomerAddress"))); oOrder.setOrderDate(cursor.getString(cursor.getColumnIndex("OrderDate"))); oOrder.setRequestDate(cursor.getString(cursor.getColumnIndex("RequestDate"))); oOrder.setMaxDebt(cursor.getInt(cursor.getColumnIndex("MaxDebt"))); oOrder.setOriginMoney(cursor.getDouble(cursor.getColumnIndex("OriginMoney"))); oOrder.setVAT(cursor.getDouble(cursor.getColumnIndex("VAT"))); oOrder.setVATMoney(cursor.getDouble(cursor.getColumnIndex("VATMoney"))); oOrder.setTotalMoney(cursor.getDouble(cursor.getColumnIndex("TotalMoney"))); oOrder.setOrderStatus(cursor.getInt(cursor.getColumnIndex("OrderStatus"))); if(cursor.getString(cursor.getColumnIndex("OrderStatus"))!=null){ if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("0")){ oOrder.setOrderStatusDesc("Đơn hàng mới"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("1")){ oOrder.setOrderStatusDesc("Đã điều chỉnh"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("2")){ oOrder.setOrderStatusDesc("Đang chờ xử lý"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("3")){ oOrder.setOrderStatusDesc("Đang vận chuyển"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("4")){ oOrder.setOrderStatusDesc("Đã hoàn tất"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("5")){ oOrder.setOrderStatusDesc("Đã hủy"); }else{ oOrder.setOrderStatusDesc(""); } } oOrder.setApproveDate(cursor.getString(cursor.getColumnIndex("ApproveDate"))); oOrder.setHandleStaff(cursor.getString(cursor.getColumnIndex("HandleStaff"))); oOrder.setDeliveryDesc(cursor.getString(cursor.getColumnIndex("DeliveryDesc"))); oOrder.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oOrder.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oOrder.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oOrder.setOrderNotes(cursor.getString(cursor.getColumnIndex("OrderNotes"))); oOrder.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); if(cursor.getString(cursor.getColumnIndex("IsPost"))!=null && cursor.getString(cursor.getColumnIndex("IsPost")).contains("1")){ oOrder.setPost(true); }else{ oOrder.setPost(false); } if(cursor.getString(cursor.getColumnIndex("IsSample"))!=null && cursor.getString(cursor.getColumnIndex("IsSample")).contains("1")){ oOrder.setSample(true); }else{ oOrder.setSample(false); } lstOrder.add(oOrder); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstOrder; }catch (Exception ex){Log.d("ERR_LOAD_SM_ORDER",ex.getMessage().toString());} return null; } public SM_Order getSMOrder(String OrderID) { try { String mSql=String.format("Select A.*,B.CustomerName,B.CustomerCode,B.LocationAddress as CustomerAddress from SM_ORDER A LEFT JOIN DM_CUSTOMER B on a.CustomerID=b.Customerid "+ " where A.OrderID='%s' order by OrderDate desc",OrderID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_Order oOrder = new SM_Order(); if (cursor.moveToFirst()) { do { oOrder.setOrderID(cursor.getString(cursor.getColumnIndex("OrderID"))); oOrder.setOrderCode(cursor.getString(cursor.getColumnIndex("OrderCode"))); oOrder.setCustomerID(cursor.getString(cursor.getColumnIndex("CustomerID"))); oOrder.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oOrder.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oOrder.setCustomerAddress(cursor.getString(cursor.getColumnIndex("CustomerAddress"))); oOrder.setOrderDate(cursor.getString(cursor.getColumnIndex("OrderDate"))); oOrder.setRequestDate(cursor.getString(cursor.getColumnIndex("RequestDate"))); oOrder.setMaxDebt(cursor.getInt(cursor.getColumnIndex("MaxDebt"))); oOrder.setOriginMoney(cursor.getDouble(cursor.getColumnIndex("OriginMoney"))); oOrder.setVAT(cursor.getDouble(cursor.getColumnIndex("VAT"))); oOrder.setVATMoney(cursor.getDouble(cursor.getColumnIndex("VATMoney"))); oOrder.setTotalMoney(cursor.getDouble(cursor.getColumnIndex("TotalMoney"))); oOrder.setOrderStatus(cursor.getInt(cursor.getColumnIndex("OrderStatus"))); if(cursor.getString(cursor.getColumnIndex("OrderStatus"))!=null){ if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("0")){ oOrder.setOrderStatusDesc("Đơn hàng mới"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("1")){ oOrder.setOrderStatusDesc("Đã điều chỉnh"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("2")){ oOrder.setOrderStatusDesc("Đang chờ xử lý"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("3")){ oOrder.setOrderStatusDesc("Đang vận chuyển"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("4")){ oOrder.setOrderStatusDesc("Đã hoàn tất"); }else if(cursor.getString(cursor.getColumnIndex("OrderStatus")).equalsIgnoreCase("5")){ oOrder.setOrderStatusDesc("Đã hủy"); }else{ oOrder.setOrderStatusDesc(""); } } oOrder.setApproveDate(cursor.getString(cursor.getColumnIndex("ApproveDate"))); oOrder.setHandleStaff(cursor.getString(cursor.getColumnIndex("HandleStaff"))); oOrder.setDeliveryDesc(cursor.getString(cursor.getColumnIndex("DeliveryDesc"))); oOrder.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oOrder.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oOrder.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oOrder.setOrderNotes(cursor.getString(cursor.getColumnIndex("OrderNotes"))); oOrder.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); if(cursor.getString(cursor.getColumnIndex("IsPost")).contains("1")){ oOrder.setPost(true); }else{ oOrder.setPost(false); } if(cursor.getString(cursor.getColumnIndex("IsSample")).contains("1")){ oOrder.setSample(true); }else{ oOrder.setSample(false); } break; } while (cursor.moveToNext()); } cursor.close(); db.close(); return oOrder; }catch (Exception ex){Log.d("ERR_LOAD_SM_ORDER",ex.getMessage().toString());} return null; } public String addSMOrder(SM_Order oOrder){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String OrderID=getSMOrderID(oOrder.getOrderDate(),oOrder.getCustomerID()); if(OrderID!=""){ if(oOrder.getOrderID().isEmpty()|| oOrder.getOrderID()==null){ oOrder.setOrderID(OrderID); } } iSq=getSizeSMOrder(oOrder.getOrderID()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("OrderID", oOrder.getOrderID()); values.put("OrderCode", oOrder.getOrderCode()); values.put("OrderDate", oOrder.getOrderDate()); values.put("RequestDate", oOrder.getRequestDate()); values.put("MaxDebt", oOrder.getMaxDebt()); values.put("OriginMoney",oOrder.getOriginMoney()); values.put("VAT", oOrder.getVAT()); values.put("VATMoney", oOrder.getVATMoney()); values.put("TotalMoney", oOrder.getTotalMoney()); values.put("OrderStatus", oOrder.getOrderStatus()); values.put("OrderNotes", oOrder.getOrderNotes()); values.put("CustomerID", oOrder.getCustomerID()); values.put("Longitude",oOrder.getLongitude()); values.put("Latitude", oOrder.getLatitude()); values.put("LocationAddress", oOrder.getLocationAddress()); values.put("SeqnoCode", oOrder.getSeqnoCode()); values.put("IsPost", oOrder.getPost()); values.put("PostDay", oOrder.getPostDay()); values.put("IsSample", oOrder.getSample()); db.insert("SM_ORDER", null, values); }else{ ContentValues values = new ContentValues(); values.put("OrderCode", oOrder.getOrderCode()); values.put("OrderDate", oOrder.getOrderDate()); values.put("RequestDate", oOrder.getRequestDate()); values.put("MaxDebt", oOrder.getMaxDebt()); values.put("OriginMoney",oOrder.getOriginMoney()); values.put("VAT", oOrder.getVAT()); values.put("VATMoney", oOrder.getVATMoney()); values.put("TotalMoney", oOrder.getTotalMoney()); values.put("OrderStatus", oOrder.getOrderStatus()); values.put("OrderNotes", oOrder.getOrderNotes()); values.put("CustomerID", oOrder.getCustomerID()); values.put("Longitude",oOrder.getLongitude()); values.put("Latitude", oOrder.getLatitude()); values.put("LocationAddress", oOrder.getLocationAddress()); values.put("IsPost", oOrder.getPost()); values.put("PostDay", oOrder.getPostDay()); values.put("IsSample", oOrder.getSample()); db.update("SM_ORDER",values,"OrderID=?" ,new String[] {String.valueOf(oOrder.getOrderID())}); } //Log.d("INS_SM_ORDER_DB","OK"); db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean editSMOrder(SM_Order oOrder){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("OrderCode", oOrder.getOrderCode()); values.put("OrderDate", oOrder.getOrderDate()); values.put("RequestDate", oOrder.getRequestDate()); values.put("MaxDebt", oOrder.getMaxDebt()); values.put("OriginMoney",oOrder.getOriginMoney()); values.put("VAT", oOrder.getVAT()); values.put("VATMoney", oOrder.getVATMoney()); values.put("TotalMoney", oOrder.getTotalMoney()); values.put("OrderStatus", oOrder.getOrderStatus()); values.put("CustomerID", oOrder.getCustomerID()); values.put("Longitude",oOrder.getLongitude()); values.put("Latitude", oOrder.getLatitude()); values.put("LocationAddress", oOrder.getLocationAddress()); values.put("SeqnoCode", oOrder.getSeqnoCode()); values.put("IsPost", oOrder.getPost()); values.put("PostDay", oOrder.getPostDay()); values.put("IsSample", oOrder.getSample()); db.update("SM_ORDER",values,"OrderID=?" ,new String[] {String.valueOf(oOrder.getOrderID())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_ORDER_ERR",e.getMessage()); return false;} } public boolean editSMOrderStatus(SM_Order oOrder){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("OrderStatus", oOrder.getOrderStatus()); values.put("IsPost", oOrder.getPost()); values.put("PostDay", oOrder.getPostDay()); db.update("SM_ORDER",values,"OrderID=?" ,new String[] {String.valueOf(oOrder.getOrderID())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_ORDER_ERR",e.getMessage()); return false;} } public boolean editSMOrderStatus2(SM_OrderStatus oOST){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("OrderStatus",oOST.getOrderStatus()); values.put("TotalMoney", oOST.getTotalMoney()); db.update("SM_ORDER",values,"OrderCode=?" ,new String[] {String.valueOf(oOST.getOrderCode())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_ORDER_ERR",e.getMessage()); return false;} } public boolean delSMOrder(SM_Order oOrder){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from SM_ORDER_DETAIL where OrderID IN(select OrderID from SM_ORDER where OrderID='%s')",oOrder.getOrderID()); try { db.execSQL(mSql); mSql=String.format("delete from SM_ORDER where OrderID='%s'",oOrder.getOrderID()); db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } /*******************/ /*SM_ORDER_DETAIL*/ /*******************/ private String getSMOrderDetailID(String mOrderID,String mProductID){ try { SQLiteDatabase db = getReadableDatabase(); String mSql=String.format("SELECT * FROM SM_ORDER_DETAIL WHERE OrderID='%s' AND ProductID='%s'",mOrderID,mProductID); Cursor cursor = db.rawQuery(mSql,null); String OrderDetailID=""; if (cursor.moveToFirst()) { do { OrderDetailID=cursor.getString(cursor.getColumnIndex("OrderDetailID")); break; } while (cursor.moveToNext()); } cursor.close(); return OrderDetailID; }catch(Exception ex){return "";} } public int getSizeSMOrderDetail(String OrderDetailID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_ORDER_DETAIL WHERE OrderDetailID=?", new String[]{OrderDetailID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public List<SM_OrderDetail> getAllSMOrderDetail(String mOrderID) { try { List<SM_OrderDetail> lstOrderDetail = new ArrayList<SM_OrderDetail>(); String mSql=String.format("Select * from SM_ORDER_DETAIL where OrderID='%s' order by OrderDetailID desc", mOrderID); //Log.d("SQL_ORDER_DETAIL",mSql); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_OrderDetail oOrderDetail = new SM_OrderDetail(); oOrderDetail.setOrderDetailID(cursor.getString(cursor.getColumnIndex("OrderDetailID"))); oOrderDetail.setOrderID(cursor.getString(cursor.getColumnIndex("OrderID"))); oOrderDetail.setProductID(cursor.getString(cursor.getColumnIndex("ProductID"))); oOrderDetail.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oOrderDetail.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); oOrderDetail.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); oOrderDetail.setSpec(cursor.getString(cursor.getColumnIndex("Spec"))); oOrderDetail.setConvertBox(cursor.getFloat(cursor.getColumnIndex("ConvertBox"))); oOrderDetail.setAmount(cursor.getInt(cursor.getColumnIndex("Amount"))); oOrderDetail.setAmountBox(cursor.getFloat(cursor.getColumnIndex("AmountBox"))); oOrderDetail.setPrice(cursor.getDouble(cursor.getColumnIndex("Price"))); oOrderDetail.setOriginMoney(cursor.getDouble(cursor.getColumnIndex("OriginMoney"))); oOrderDetail.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oOrderDetail.setNotes2(cursor.getString(cursor.getColumnIndex("Notes2"))); lstOrderDetail.add(oOrderDetail); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstOrderDetail; }catch (Exception ex){Log.d("ERR_LOAD_ORDER_DETAIL",ex.getMessage().toString());} return null; } public SM_OrderDetail getSMOrderDetail(String mOrderDetailID) { try { String mSql=String.format("Select * from SM_ORDER_DETAIL where OrderDetailID='%$' order by OrderDetailID desc",mOrderDetailID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_OrderDetail oOrderDetail = new SM_OrderDetail(); if (cursor.moveToFirst()) { do { oOrderDetail.setOrderDetailID(cursor.getString(cursor.getColumnIndex("OrderDetailID"))); oOrderDetail.setOrderID(cursor.getString(cursor.getColumnIndex("OrderID"))); oOrderDetail.setProductID(cursor.getString(cursor.getColumnIndex("ProductID"))); oOrderDetail.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oOrderDetail.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); oOrderDetail.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); oOrderDetail.setSpec(cursor.getString(cursor.getColumnIndex("Spec"))); oOrderDetail.setConvertBox(cursor.getFloat(cursor.getColumnIndex("ConvertBox"))); oOrderDetail.setAmount(cursor.getInt(cursor.getColumnIndex("Amount"))); oOrderDetail.setAmountBox(cursor.getFloat(cursor.getColumnIndex("AmountBox"))); oOrderDetail.setPrice(cursor.getDouble(cursor.getColumnIndex("Price"))); oOrderDetail.setOriginMoney(cursor.getDouble(cursor.getColumnIndex("OriginMoney"))); oOrderDetail.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oOrderDetail.setNotes2(cursor.getString(cursor.getColumnIndex("Notes2"))); break; } while (cursor.moveToNext()); } cursor.close(); db.close(); return oOrderDetail; }catch (Exception ex){Log.d("ERR_LOAD_ORDER_DETAIL",ex.getMessage().toString());} return null; } public String addSMOrderDetail(SM_OrderDetail oOrderDetail){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String mOrderDetailID=getSMOrderDetailID(oOrderDetail.getOrderID(),oOrderDetail.getProductID()); if(mOrderDetailID.isEmpty()|| mOrderDetailID=="" ){ ContentValues values = new ContentValues(); values.put("OrderDetailID", oOrderDetail.getOrderDetailID()); values.put("OrderID", oOrderDetail.getOrderID()); values.put("ProductID", oOrderDetail.getProductID()); values.put("ProductCode", oOrderDetail.getProductCode()); values.put("ProductName", oOrderDetail.getProductName()); values.put("Unit", oOrderDetail.getUnit()); values.put("Spec",oOrderDetail.getSpec()); values.put("ConvertBox",oOrderDetail.getConvertBox()); values.put("Amount", oOrderDetail.getAmount()); values.put("AmountBox", oOrderDetail.getAmountBox()); values.put("Price",oOrderDetail.getPrice()); values.put("OriginMoney", oOrderDetail.getOriginMoney()); values.put("Notes", oOrderDetail.getNotes()); values.put("Notes2", oOrderDetail.getNotes2()); db.insert("SM_ORDER_DETAIL", null, values); }else{ ContentValues values = new ContentValues(); values.put("OrderDetailID", oOrderDetail.getOrderDetailID()); values.put("OrderID", oOrderDetail.getOrderID()); values.put("ProductID", oOrderDetail.getProductID()); values.put("ProductCode", oOrderDetail.getProductCode()); values.put("ProductName", oOrderDetail.getProductName()); values.put("Unit", oOrderDetail.getUnit()); values.put("Spec",oOrderDetail.getSpec()); values.put("ConvertBox",oOrderDetail.getConvertBox()); values.put("Amount", oOrderDetail.getAmount()); values.put("AmountBox", oOrderDetail.getAmountBox()); values.put("Price",oOrderDetail.getPrice()); values.put("OriginMoney", oOrderDetail.getOriginMoney()); values.put("Notes", oOrderDetail.getNotes()); values.put("Notes2", oOrderDetail.getNotes2()); db.update("SM_ORDER_DETAIL",values,"OrderDetailID=?" ,new String[] {String.valueOf(oOrderDetail.getOrderDetailID())}); } //Log.d("INS_ORDERDETAIL_DB","OK"); db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean delSMOrderDetail(SM_OrderDetail oOrderDetail){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from SM_ORDER_DETAIL where OrderDetailID ='%s'",oOrderDetail.getOrderDetailID()); try { db.execSQL(mSql); }catch (Exception ex){ //Log.d("DEL_SM_ORDER",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } public boolean delAllSMOrderDetail(String mOrderID){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from SM_ORDER_DETAIL where OrderID ='%s'",mOrderID); try { db.execSQL(mSql); }catch (Exception ex){ Log.d("DEL_SM_ODT",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } /****SM_DELIVERY_ORDER****/ private String getDeliveryID(String mOrderID,String mTransportCode){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_DELIVERY_ORDER WHERE (OrderID='%s' AND TransportCode='%s')", new String[]{mOrderID,mTransportCode}); String mDeliveryOrderID=""; if (cursor.moveToFirst()) { do { mDeliveryOrderID=cursor.getString(cursor.getColumnIndex("DeliveryOrderID")); break; } while (cursor.moveToNext()); } cursor.close(); return mDeliveryOrderID; }catch(Exception ex){return "";} } public List<SM_OrderDelivery> getAllDelivery(String mOrderID) { try { List<SM_OrderDelivery> lstOrderDetail = new ArrayList<SM_OrderDelivery>(); String mSql=String.format("Select A.* from SM_DELIVERY_ORDER A where A.OrderID='%s' order by DeliveryNum asc",mOrderID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_OrderDelivery oOrderDelivery = new SM_OrderDelivery(); oOrderDelivery.setDeliveryOrderID(cursor.getString(cursor.getColumnIndex( "DeliveryOrderID"))); oOrderDelivery.setOrderID(cursor.getString(cursor.getColumnIndex("OrderID"))); oOrderDelivery.setTransportCode(cursor.getString(cursor.getColumnIndex("TransportCode"))); oOrderDelivery.setNumberPlate(cursor.getString(cursor.getColumnIndex("NumberPlate"))); oOrderDelivery.setCarType(cursor.getString(cursor.getColumnIndex("CarType"))); oOrderDelivery.setDeliveryStaff(cursor.getString(cursor.getColumnIndex("DeliveryStaff"))); oOrderDelivery.setDeliveryNum(cursor.getInt(cursor.getColumnIndex("DeliveryNum"))); oOrderDelivery.setDeliveryDate(cursor.getString(cursor.getColumnIndex("DeliveryDate"))); oOrderDelivery.setHandlingStaff(cursor.getString(cursor.getColumnIndex("HandlingStaff"))); oOrderDelivery.setHandlingDate(cursor.getString(cursor.getColumnIndex("HandlingDate"))); oOrderDelivery.setTotalMoney(cursor.getFloat(cursor.getColumnIndex("TotalMoney"))); oOrderDelivery.setDeliveryDesc(cursor.getString(cursor.getColumnIndex("DeliveryDesc"))); lstOrderDetail.add(oOrderDelivery); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstOrderDetail; }catch (Exception ex){Log.d("ERR_LOAD_ORDER_DETAIL",ex.getMessage().toString());} return null; } public String addDelivery(SM_OrderDelivery oOrderDelivery){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String mOrderDeliveryID=getDeliveryID(oOrderDelivery.getOrderID(),oOrderDelivery.getTransportCode()); if(mOrderDeliveryID==null || mOrderDeliveryID.isEmpty()|| mOrderDeliveryID=="" ){ ContentValues values = new ContentValues(); values.put("DeliveryOrderID", oOrderDelivery.getDeliveryOrderID()); values.put("OrderID", oOrderDelivery.getOrderID()); values.put("TransportCode",oOrderDelivery.getTransportCode()); values.put("NumberPlate", oOrderDelivery.getNumberPlate()); values.put("CarType", oOrderDelivery.getCarType()); values.put("DeliveryStaff", oOrderDelivery.getDeliveryStaff()); values.put("DeliveryNum",oOrderDelivery.getDeliveryNum()); values.put("DeliveryDate",oOrderDelivery.getDeliveryDate()); values.put("HandlingStaff", oOrderDelivery.getHandlingStaff()); values.put("HandlingDate",oOrderDelivery.getHandlingDate()); values.put("TotalMoney",oOrderDelivery.getTotalMoney()); values.put("DeliveryDesc",oOrderDelivery.getDeliveryDesc()); db.insert("SM_DELIVERY_ORDER", null, values); }else{ ContentValues values = new ContentValues(); values.put("DeliveryOrderID", oOrderDelivery.getDeliveryOrderID()); values.put("OrderID", oOrderDelivery.getOrderID()); values.put("TransportCode",oOrderDelivery.getTransportCode()); values.put("NumberPlate", oOrderDelivery.getNumberPlate()); values.put("CarType", oOrderDelivery.getCarType()); values.put("DeliveryStaff", oOrderDelivery.getDeliveryStaff()); values.put("DeliveryNum",oOrderDelivery.getDeliveryNum()); values.put("DeliveryDate",oOrderDelivery.getDeliveryDate()); values.put("HandlingStaff", oOrderDelivery.getHandlingStaff()); values.put("HandlingDate",oOrderDelivery.getHandlingDate()); values.put("TotalMoney",oOrderDelivery.getTotalMoney()); values.put("DeliveryDesc",oOrderDelivery.getDeliveryDesc()); db.update("SM_DELIVERY_ORDER",values,"DeliveryOrderID=?" ,new String[] {String.valueOf(mOrderDeliveryID)}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean delDelivery(String mDeliveryID){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from SM_DELIVERY_ORDER_DETAIL where DeliveryOrderID ='%s'",mDeliveryID); try { db.execSQL(mSql); mSql=String.format("delete from SM_DELIVERY_ORDER where DeliveryOrderID ='%s'",mDeliveryID); db.execSQL(mSql); return true; }catch (Exception ex){ return false; } }catch (Exception ex){return false;} } //DELIVERY DETAIL public List<SM_OrderDeliveryDetail> getAllDeliveryDetail(String mDeliveryOrderID) { try { List<SM_OrderDeliveryDetail> lstOrderDetail = new ArrayList<SM_OrderDeliveryDetail>(); String mSql=String.format("Select A.* from SM_DELIVERY_ORDER_DETAIL A where A.DeliveryOrderID='%s' order by ProductCode asc",mDeliveryOrderID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_OrderDeliveryDetail oDLT = new SM_OrderDeliveryDetail(); oDLT.setDeliveryOrderDetailID(cursor.getString(cursor.getColumnIndex( "DeliveryOrderDetailID"))); oDLT.setDeliveryOrderID(cursor.getString(cursor.getColumnIndex( "DeliveryOrderID"))); oDLT.setProductCode(cursor.getString(cursor.getColumnIndex( "ProductCode"))); oDLT.setProductName(cursor.getString(cursor.getColumnIndex( "ProductName"))); oDLT.setUnit(cursor.getString(cursor.getColumnIndex( "Unit"))); oDLT.setSpec(cursor.getString(cursor.getColumnIndex( "Spec"))); oDLT.setAmount(cursor.getInt(cursor.getColumnIndex( "Amount"))); oDLT.setAmountBox(cursor.getFloat(cursor.getColumnIndex( "AmountBox"))); oDLT.setPrice(cursor.getFloat(cursor.getColumnIndex( "Price"))); oDLT.setOriginMoney(cursor.getFloat(cursor.getColumnIndex( "OriginMoney"))); oDLT.setNotes(cursor.getString(cursor.getColumnIndex( "Notes"))); lstOrderDetail.add(oDLT); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstOrderDetail; }catch (Exception ex){Log.d("ERR_LOAD_ORDER_DETAIL",ex.getMessage().toString());} return null; } private String getDeliveryDetailID(String mDeliveryOrderID,String mProductCode){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_DELIVERY_ORDER_DETAIL WHERE (DeliveryOrderID='%s' AND ProductCode='%s')", new String[]{mDeliveryOrderID,mProductCode}); String mDeliveryOrderDetailID=""; if (cursor.moveToFirst()) { do { mDeliveryOrderDetailID=cursor.getString(cursor.getColumnIndex("DeliveryOrderDetailID")); break; } while (cursor.moveToNext()); } cursor.close(); return mDeliveryOrderDetailID; }catch(Exception ex){return "";} } public String addDeliveryDetail(SM_OrderDeliveryDetail oDLT){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String mDeliveryDetailID=getDeliveryDetailID(oDLT.getDeliveryOrderID(),oDLT.getProductCode()); if(mDeliveryDetailID==null || mDeliveryDetailID.isEmpty()|| mDeliveryDetailID=="" ){ ContentValues values = new ContentValues(); values.put("DeliveryOrderDetailID",oDLT.getDeliveryOrderDetailID()); values.put("DeliveryOrderID", oDLT.getDeliveryOrderID()); values.put("ProductCode",oDLT.getProductCode()); values.put("ProductName", oDLT.getProductName()); values.put("Unit", oDLT.getUnit()); values.put("Spec", oDLT.getSpec()); values.put("Amount",oDLT.getAmount()); values.put("AmountBox",oDLT.getAmountBox()); values.put("Price",oDLT.getPrice()); values.put("OriginMoney", oDLT.getOriginMoney()); values.put("Notes",oDLT.getNotes()); db.insert("SM_DELIVERY_ORDER_DETAIL", null, values); }else{ ContentValues values = new ContentValues(); values.put("DeliveryOrderID", oDLT.getDeliveryOrderID()); values.put("ProductCode",oDLT.getProductCode()); values.put("ProductName", oDLT.getProductName()); values.put("Unit", oDLT.getUnit()); values.put("Spec", oDLT.getSpec()); values.put("Amount",oDLT.getAmount()); values.put("AmountBox",oDLT.getAmountBox()); values.put("Price",oDLT.getPrice()); values.put("OriginMoney", oDLT.getOriginMoney()); values.put("Notes",oDLT.getNotes()); db.update("SM_DELIVERY_ORDER_DETAIL",values,"DeliveryOrderDetailID=?" ,new String[] {String.valueOf(mDeliveryDetailID)}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean delAllDeliveryDetail(String mDeliveryID){ try { SQLiteDatabase db = getWritableDatabase(); String mSql=String.format("delete from SM_DELIVERY_ORDER_DETAIL where DeliveryOrderID ='%s'",mDeliveryID); try { db.execSQL(mSql); return true; }catch (Exception ex){ return false; } }catch (Exception ex){return false;} } /*******GĐ-2*************/ /****DM_TREE*****/ public int getSizeTree(String Treeid){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_TREE WHERE TreeID=?",new String[]{Treeid}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addTree(DM_Tree oDM){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeTree(Integer.toString(oDM.getTreeID())); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("TreeID",oDM.getTreeID()); values.put("TreeCode",oDM.getTreeCode()); values.put("TreeGroupCode", oDM.getTreeGroupCode()); values.put("TreeName", oDM.getTreeName()); db.insert("DM_TREE", null, values); }else{ iSq=iSq+1; ContentValues values = new ContentValues(); values.put("TreeCode",oDM.getTreeCode()); values.put("TreeGroupCode", oDM.getTreeGroupCode()); values.put("TreeName", oDM.getTreeName()); db.update("DM_TREE",values,"TreeID=?" ,new String[] { String.valueOf(oDM.getTreeID())}); } db.close(); return true; }catch (Exception e){Log.v("INS_DISTRICT_ERR",e.getMessage()); return false;} } public List<DM_Tree> getAllTree() { List<DM_Tree> lstPara = new ArrayList<DM_Tree>(); String selectQuery = "SELECT TreeID,TreeCode,TreeGroupCode,TreeName FROM DM_TREE ORDER BY TreeName ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Tree oPara = new DM_Tree(); oPara.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oPara.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oPara.setTreeGroupCode(cursor.getString(cursor.getColumnIndex("TreeGroupCode"))); oPara.setTreeName(cursor.getString(cursor.getColumnIndex("TreeName"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public List<DM_Tree> getTree(Integer TreeID) { List<DM_Tree> lstPara = new ArrayList<DM_Tree>(); String selectQuery = String.format("SELECT TreeID,TreeCode,TreeGroupCode,TreeName FROM DM_TREE where TreeID='%d' ORDER BY TreeName ASC",TreeID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Tree oPara = new DM_Tree(); oPara.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oPara.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oPara.setTreeGroupCode(cursor.getString(cursor.getColumnIndex("TreeGroupCode"))); oPara.setTreeName(cursor.getString(cursor.getColumnIndex("TreeName"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public boolean delTree(String TreeID,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_TREE"); }else{ mSql = String.format("delete from DM_TREE where TreeID='%s'",TreeID); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } /****DM_TREE_DISEASE [DỊCH HẠI]*****/ public int getSizeTreeDisease(String DiseaseID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_TREE_DISEASE WHERE DiseaseID=?",new String[]{DiseaseID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return 0;} } public boolean addTreeDisease(DM_Tree_Disease oDM){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeTreeDisease(Integer.toString(oDM.getDiseaseID())); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("DiseaseID",oDM.getDiseaseID()); values.put("TreeID",oDM.getTreeID()); values.put("DiseaseCode",oDM.getDiseaseCode()); values.put("DiseaseName",oDM.getDiseaseName()); db.insert("DM_TREE_DISEASE", null, values); }else{ iSq=iSq+1; ContentValues values = new ContentValues(); values.put("TreeID",oDM.getTreeID()); values.put("DiseaseCode",oDM.getDiseaseCode()); values.put("DiseaseName", oDM.getDiseaseName()); db.update("DM_TREE_DISEASE",values,"DiseaseID=?" ,new String[] { String.valueOf(oDM.getDiseaseID())}); } db.close(); return true; }catch (Exception e){Log.v("INS_DISEASE_ERR",e.getMessage()); return false;} } public List<DM_Tree_Disease> getAllTreeDisease() { List<DM_Tree_Disease> lstPara = new ArrayList<DM_Tree_Disease>(); String selectQuery = "SELECT A.DiseaseID,A.TreeID,A.DiseaseCode,A.DiseaseName,B.TreeName FROM DM_TREE_DISEASE A LEFT JOIN DM_TREE B ON A.TreeID=B.TreeID ORDER BY A.TreeID, DiseaseName ASC"; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Tree_Disease oPara = new DM_Tree_Disease(); oPara.setDiseaseID(cursor.getInt(cursor.getColumnIndex("DiseaseID"))); oPara.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oPara.setDiseaseCode(cursor.getString(cursor.getColumnIndex("DiseaseCode"))); oPara.setDiseaseName(cursor.getString(cursor.getColumnIndex("DiseaseName"))); oPara.setTreeName(cursor.getString(cursor.getColumnIndex("TreeName"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public List<DM_Tree_Disease> getTreeDisease(Integer DiseaseID) { List<DM_Tree_Disease> lstPara = new ArrayList<DM_Tree_Disease>(); String selectQuery = String.format("SELECT A.DiseaseID,A.TreeID,A.DiseaseCode,A.DiseaseName,B.TreeName FROM DM_TREE_DISEASE A LEFT JOIN DM_TREE B ON A.TreeID=B.TreeID where A.DiseaseID='%d' ORDER BY A.TreeID,DiseaseName ASC",DiseaseID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { DM_Tree_Disease oPara = new DM_Tree_Disease(); oPara.setDiseaseID(cursor.getInt(cursor.getColumnIndex("DiseaseID"))); oPara.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oPara.setDiseaseCode(cursor.getString(cursor.getColumnIndex("DiseaseCode"))); oPara.setDiseaseName(cursor.getString(cursor.getColumnIndex("DiseaseName"))); oPara.setTreeName(cursor.getString(cursor.getColumnIndex("TreeName"))); lstPara.add(oPara); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPara; } public boolean delTreeDisease(String DiseaseID,boolean isAll){ try { String mSql; SQLiteDatabase db = getWritableDatabase(); if(isAll) { mSql = String.format("delete from DM_TREE_DISEASE"); }else{ mSql = String.format("delete from DM_TREE_DISEASE where DiseaseID='%s'",DiseaseID); } try { db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } /*<<SM-CUSTOMER-PAY>>*/ /********************/ public boolean getCheckPayStatus(String mToday){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_CUSTOMER_PAY WHERE PayStatus<=3",null); int iSq= cursor.getCount(); cursor.close(); if (iSq>0){return true;}else{return false;} }catch(Exception ex){return false;} } private String getPayID(String PayDay,String mCustomerID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_CUSTOMER_PAY WHERE (julianday(OrderDate)-julianday('%s')=0) and CustomerID='%s' ", new String[]{PayDay,mCustomerID}); String PayID=""; if (cursor.moveToFirst()) { do { PayID=cursor.getString(cursor.getColumnIndex("PayID")); break; } while (cursor.moveToNext()); } cursor.close(); return PayID; }catch(Exception ex){return "";} } public int getSizePay(String PayID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_CUSTOMER_PAY WHERE PayID=?", new String[]{PayID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanCustomerPay(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_CUSTOMER_PAY where PayID in(select PayID from SM_CUSTOMER_PAY where julianday('now')-julianday(PayDate)>%s)", iIntervalDay); db.execSQL(mSql); mSql = String.format("delete from SM_CUSTOMER_PAY where julianday('now')-julianday(PayDate)>%s", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_CustomerPay> getAllCustomerPay(String fday, String tDay) { try { List<SM_CustomerPay> lstPay = new ArrayList<SM_CustomerPay>(); String mSql=String.format("Select A.*,B.CustomerName,B.CustomerCode from SM_CUSTOMER_PAY A LEFT JOIN DM_CUSTOMER B on ifnull(a.CustomerID,'')=b.Customerid "+ " where (julianday(A.PayDate)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.PayDate)) >=0 order by PayDate desc",fday,tDay); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_CustomerPay oPay = new SM_CustomerPay(); oPay.setPayID(cursor.getString(cursor.getColumnIndex("PayID"))); oPay.setPayCode(cursor.getString(cursor.getColumnIndex("PayCode"))); oPay.setCustomerID(cursor.getString(cursor.getColumnIndex("CustomerID"))); oPay.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oPay.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oPay.setPayDate(cursor.getString(cursor.getColumnIndex("PayDate"))); oPay.setPayName(cursor.getString(cursor.getColumnIndex("PayName"))); oPay.setPayNotes(cursor.getString(cursor.getColumnIndex("PayNotes"))); oPay.setPayMoney(cursor.getDouble(cursor.getColumnIndex("PayMoney"))); oPay.setPayPic(cursor.getString(cursor.getColumnIndex("PayPic"))); oPay.setPayStatus(cursor.getInt(cursor.getColumnIndex("PayStatus"))); if(cursor.getString(cursor.getColumnIndex("PayStatus"))!=null){ if(cursor.getString(cursor.getColumnIndex("PayStatus")).equalsIgnoreCase("0")){ oPay.setPayStatusDesc("Phiếu mới"); }else if(cursor.getString(cursor.getColumnIndex("PayStatus")).equalsIgnoreCase("1")){ oPay.setPayStatusDesc("Đã điều chỉnh"); }else if(cursor.getString(cursor.getColumnIndex("PayStatus")).equalsIgnoreCase("3")){ oPay.setPayStatusDesc("Đã hủy"); }else{ oPay.setPayStatusDesc(""); } } oPay.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oPay.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oPay.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oPay.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); if(cursor.getString(cursor.getColumnIndex("IsPost"))!=null && cursor.getString(cursor.getColumnIndex("IsPost")).contains("1")){ oPay.setPost(true); }else{ oPay.setPost(false); } lstPay.add(oPay); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lstPay; }catch (Exception ex){Log.d("ERR_LOAD_SM_PAY",ex.getMessage().toString());} return null; } public SM_CustomerPay getCustomerPay(String PayID) { try { String mSql=String.format("Select A.*,B.CustomerName,B.CustomerCode from SM_CUSTOMER_PAY A LEFT JOIN DM_CUSTOMER B on a.CustomerID=b.Customerid "+ " where A.PayID='%s' order by PayDate desc",PayID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_CustomerPay oPay = new SM_CustomerPay(); if (cursor.moveToFirst()) { do { oPay.setPayID(cursor.getString(cursor.getColumnIndex("PayID"))); oPay.setPayCode(cursor.getString(cursor.getColumnIndex("PayCode"))); oPay.setCustomerID(cursor.getString(cursor.getColumnIndex("CustomerID"))); oPay.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); oPay.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); oPay.setPayDate(cursor.getString(cursor.getColumnIndex("PayDate"))); oPay.setPayName(cursor.getString(cursor.getColumnIndex("PayName"))); oPay.setPayNotes(cursor.getString(cursor.getColumnIndex("PayNotes"))); oPay.setPayMoney(cursor.getDouble(cursor.getColumnIndex("PayMoney"))); oPay.setPayPic(cursor.getString(cursor.getColumnIndex("PayPic"))); oPay.setPayStatus(cursor.getInt(cursor.getColumnIndex("PayStatus"))); if(cursor.getString(cursor.getColumnIndex("PayStatus"))!=null){ if(cursor.getString(cursor.getColumnIndex("PayStatus")).equalsIgnoreCase("0")){ oPay.setPayStatusDesc("Phiếu mới"); }else if(cursor.getString(cursor.getColumnIndex("PayStatus")).equalsIgnoreCase("1")){ oPay.setPayStatusDesc("Đã điều chỉnh"); }else if(cursor.getString(cursor.getColumnIndex("PayStatus")).equalsIgnoreCase("3")){ oPay.setPayStatusDesc("Đã hủy"); }else{ oPay.setPayStatusDesc(""); } } oPay.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude"))); oPay.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude"))); oPay.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oPay.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); if(cursor.getString(cursor.getColumnIndex("IsPost"))!=null && cursor.getString(cursor.getColumnIndex("IsPost")).contains("1")){ oPay.setPost(true); }else{ oPay.setPost(false); } break; } while (cursor.moveToNext()); } cursor.close(); db.close(); return oPay; }catch (Exception ex){Log.d("ERR_LOAD_SM_ORDER",ex.getMessage().toString());} return null; } public String addCustomerPay(SM_CustomerPay oPay){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String PayID=getPayID(oPay.getPayDate(),oPay.getCustomerID()); if(PayID!=""){ if(oPay.getPayID().isEmpty()|| oPay.getPayID()==null){ oPay.setPayID(PayID); } } iSq=getSizePay(oPay.getPayID()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("PayID", oPay.getPayID()); values.put("PayCode", oPay.getPayCode()); values.put("PayDate", oPay.getPayDate()); values.put("PayName", oPay.getPayName()); values.put("PayMoney",oPay.getPayMoney()); values.put("PayNotes", oPay.getPayNotes()); values.put("PayStatus", oPay.getPayStatus()); values.put("PayPic", oPay.getPayPic()); values.put("CustomerID", oPay.getCustomerID()); values.put("Longitude",oPay.getLongitude()); values.put("Latitude", oPay.getLatitude()); values.put("LocationAddress", oPay.getLocationAddress()); values.put("IsPost", oPay.getPost()); values.put("PostDay", oPay.getPostDay()); db.insert("SM_CUSTOMER_PAY", null, values); }else{ ContentValues values = new ContentValues(); values.put("PayCode", oPay.getPayCode()); values.put("PayDate", oPay.getPayDate()); values.put("PayName", oPay.getPayName()); values.put("PayMoney",oPay.getPayMoney()); values.put("PayNotes", oPay.getPayNotes()); values.put("PayStatus", oPay.getPayStatus()); values.put("PayPic", oPay.getPayPic()); values.put("CustomerID", oPay.getCustomerID()); values.put("Longitude",oPay.getLongitude()); values.put("Latitude", oPay.getLatitude()); values.put("LocationAddress", oPay.getLocationAddress()); values.put("IsPost", oPay.getPost()); values.put("PostDay", oPay.getPostDay()); db.update("SM_CUSTOMER_PAY",values,"PayID=?" ,new String[] {String.valueOf(oPay.getPayID())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean editCustomerPay(SM_CustomerPay oPay){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("PayCode", oPay.getPayCode()); values.put("PayDate", oPay.getPayDate()); values.put("PayName", oPay.getPayName()); values.put("PayMoney",oPay.getPayMoney()); values.put("PayNotes", oPay.getPayNotes()); values.put("PayStatus", oPay.getPayStatus()); values.put("PayPic", oPay.getPayPic()); values.put("CustomerID", oPay.getCustomerID()); values.put("Longitude",oPay.getLongitude()); values.put("Latitude", oPay.getLatitude()); values.put("LocationAddress", oPay.getLocationAddress()); values.put("IsPost", oPay.getPost()); values.put("PostDay", oPay.getPostDay()); db.update("SM_CUSTOMER_PAY",values,"PayID=?" ,new String[] {String.valueOf(oPay.getPayID())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_ORDER_ERR",e.getMessage()); return false;} } public boolean editCustomerPayStatus(SM_CustomerPay oPay){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("PayStatus", oPay.getPayStatus()); values.put("IsPost", oPay.getPost()); values.put("PostDay", oPay.getPostDay()); db.update("SM_CUSTOMER_PAY",values,"PayID=?" ,new String[] {String.valueOf(oPay.getPayID())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_PAY_ERR",e.getMessage()); return false;} } public boolean delCustomerPay(SM_CustomerPay oPay){ try { SQLiteDatabase db = getWritableDatabase(); try { String mSql=String.format("delete from SM_CUSTOMER_PAY where PayID='%s'",oPay.getPayID()); db.execSQL(mSql); }catch (Exception ex){ return false; } return true; }catch (Exception ex){return false;} } /* REPORT TECH */ public boolean getIsStatus(String mToday){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH WHERE IsStatus<=3",null); int iSq= cursor.getCount(); cursor.close(); if (iSq>0){return true;}else{return false;} }catch(Exception ex){return false;} } private String getReportTechId(String ReportDate){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH WHERE (julianday(ReportDay)-julianday('%s')=0) ", new String[]{ReportDate}); String ReportTechId=""; if (cursor.moveToFirst()) { do { ReportTechId=cursor.getString(cursor.getColumnIndex("ReportTechID")); break; } while (cursor.moveToNext()); } cursor.close(); return ReportTechId; }catch(Exception ex){return "";} } public int getSizeReportTech(String ReportTechID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH WHERE ReportTechID=?", new String[]{ReportTechID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportTech(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_TECH where ReportTechID in(select ReportTechID from SM_REPORT_TECH where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); mSql = String.format("delete from SM_REPORT_TECH where julianday('now')-julianday(ReportDay)>%s", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportTech> getAllReportTech(String fday, String tDay) { try { List<SM_ReportTech> lst = new ArrayList<SM_ReportTech>(); String mSql=String.format("Select A.* from SM_REPORT_TECH A"+ " where (julianday(A.ReportDay)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.ReportDay)) >=0 order by A.ReportDay desc",fday,tDay); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportTech oRptTech = new SM_ReportTech(); oRptTech.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTech.setReportCode(cursor.getString(cursor.getColumnIndex("ReportCode"))); oRptTech.setReportName(cursor.getString(cursor.getColumnIndex("ReportName"))); oRptTech.setReportDate(cursor.getString(cursor.getColumnIndex("ReportDay"))); oRptTech.setLongtitude(cursor.getFloat(cursor.getColumnIndex("Longitude"))); oRptTech.setLatitude(cursor.getFloat(cursor.getColumnIndex("Latitude"))); oRptTech.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oRptTech.setReceiverList(cursor.getString(cursor.getColumnIndex("ReceiverList"))); oRptTech.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); String isStatus = cursor.getString(cursor.getColumnIndex("IsStatus")); if(isStatus != null) { if(isStatus.equalsIgnoreCase("0")) { oRptTech.setIsStatus("Phiếu mới"); } else if(isStatus.equalsIgnoreCase("1")) { oRptTech.setIsStatus("Đã điều chỉnh"); } else if(isStatus.equalsIgnoreCase("3")) { oRptTech.setIsStatus("Đã hủy"); } else { oRptTech.setIsStatus(""); } } String isPost = cursor.getString(cursor.getColumnIndex("IsPost")); if(isPost.equalsIgnoreCase("1")) { oRptTech.setPost(true); }else{ oRptTech.setPost(false); } oRptTech.setPostDate(cursor.getString(cursor.getColumnIndex("PostDay"))); lst.add(oRptTech); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SM_PAY",ex.getMessage().toString());} return null; } public SM_ReportTech getReportTechById(String reportTechId) { try { String mSql=String.format("Select A.* from SM_REPORT_TECH A "+ " where A.ReportTechID='%s' order by ReportDay desc",reportTechId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportTech oRptTech = new SM_ReportTech(); if (cursor.moveToFirst()) { do { oRptTech.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTech.setReportCode(cursor.getString(cursor.getColumnIndex("ReportCode"))); oRptTech.setReportName(cursor.getString(cursor.getColumnIndex("ReportName"))); oRptTech.setReportDate(cursor.getString(cursor.getColumnIndex("ReportDay"))); oRptTech.setLongtitude(cursor.getFloat(cursor.getColumnIndex("Longitude"))); oRptTech.setLatitude(cursor.getFloat(cursor.getColumnIndex("Latitude"))); oRptTech.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oRptTech.setReceiverList(cursor.getString(cursor.getColumnIndex("ReceiverList"))); oRptTech.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); String isStatus = cursor.getString(cursor.getColumnIndex("IsStatus")); if(isStatus != null) { if(isStatus.equalsIgnoreCase("0")) { oRptTech.setIsStatus("Phiếu mới"); } else if(isStatus.equalsIgnoreCase("1")) { oRptTech.setIsStatus("Đã điều chỉnh"); } else if(isStatus.equalsIgnoreCase("3")) { oRptTech.setIsStatus("Đã hủy"); } else { oRptTech.setIsStatus(""); } } String isPost = cursor.getString(cursor.getColumnIndex("IsPost")); if(isPost.equalsIgnoreCase("1")) { oRptTech.setPost(true); }else{ oRptTech.setPost(false); } oRptTech.setPostDate(cursor.getString(cursor.getColumnIndex("PostDay"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptTech; }catch (Exception ex){ Log.d("ERR_LOAD_SM_PAY",ex.getMessage().toString()); } return null; } public boolean editReportTech(SM_ReportTech oRptTech){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("ReportCode", oRptTech.getReportCode()); values.put("ReportName", oRptTech.getReportName()); values.put("ReportDay", oRptTech.getReportDate()); values.put("Longitude", oRptTech.getLongtitude()); values.put("Latitude", oRptTech.getLatitude()); values.put("LocationAddress", oRptTech.getLocationAddress()); values.put("ReceiverList", oRptTech.getReceiverList()); values.put("Notes", oRptTech.getNotes()); values.put("IsStatus", oRptTech.getIsStatus()); values.put("IsPost", oRptTech.isPost()); values.put("PostDay", oRptTech.getPostDate()); //db.update("SM_REPORT_TECH",values,"ReportCode=?" ,new String[] {String.valueOf(oRptTech.getReportCode())}); db.update("SM_REPORT_TECH",values,"ReportTechID=?" ,new String[] {String.valueOf(oRptTech.getReportTechId())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_RPT_TECH_ERR",e.getMessage()); return false;} } public String addReportTech(SM_ReportTech oRptTech){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String ReportTechID=getReportTechId(oRptTech.getReportDate()); if(ReportTechID!=""){ if(oRptTech.getReportTechId().isEmpty()|| oRptTech.getReportTechId()==null){ oRptTech.setReportTechId(ReportTechID); } } iSq=getSizeReportTech(oRptTech.getReportTechId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("ReportTechID", oRptTech.getReportTechId()); values.put("ReportCode", oRptTech.getReportCode()); values.put("ReportName", oRptTech.getReportName()); values.put("ReportDay", oRptTech.getReportDate()); values.put("Longitude", oRptTech.getLongtitude()); values.put("Latitude", oRptTech.getLatitude()); values.put("LocationAddress", oRptTech.getLocationAddress()); values.put("ReceiverList", oRptTech.getReceiverList()); values.put("Notes", oRptTech.getNotes()); values.put("IsStatus", oRptTech.getIsStatus()); values.put("IsPost", oRptTech.isPost()); values.put("PostDay", oRptTech.getPostDate()); db.insert("SM_REPORT_TECH", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportCode", oRptTech.getReportCode()); values.put("ReportName", oRptTech.getReportName()); values.put("ReportDay", oRptTech.getReportDate()); values.put("Longitude", oRptTech.getLongtitude()); values.put("Latitude", oRptTech.getLatitude()); values.put("LocationAddress", oRptTech.getLocationAddress()); values.put("ReceiverList", oRptTech.getReceiverList()); values.put("Notes", oRptTech.getNotes()); values.put("IsStatus", oRptTech.getIsStatus()); values.put("IsPost", oRptTech.isPost()); values.put("PostDay", oRptTech.getPostDate()); db.update("SM_REPORT_TECH",values,"ReportTechID=?" ,new String[] {String.valueOf(oRptTech.getReportTechId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT TECH */ /* REPORT TECH THỊ TRƯỜNG */ private String getReportTechMarketID(String ReportTechID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_TECH_MARKET A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID WHERE B.ReportTechID=? ", new String[]{ReportTechID}); String MarketID=""; if (cursor.moveToFirst()) { do { MarketID=cursor.getString(cursor.getColumnIndex("MarketID")); break; } while (cursor.moveToNext()); } cursor.close(); return MarketID; }catch(Exception ex){return "";} } public int getSizeReportTechMarket(String MarketID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH_MARKET WHERE MarketID=?", new String[]{MarketID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportTechMarket(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_TECH_MARKET where ReportTechID in(select ReportTechID from SM_REPORT_TECH where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportTechMarket> getAllReportTechMarket(String mReportTechId) { try { List<SM_ReportTechMarket> lst = new ArrayList<SM_ReportTechMarket>(); String mSql=String.format("Select A.* from SM_REPORT_TECH_MARKET A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID"+ " where A.ReportTechID='%s' order by B.ReportDay desc", mReportTechId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportTechMarket oRptTechMarket = new SM_ReportTechMarket(); oRptTechMarket.setMarketId(cursor.getString(cursor.getColumnIndex("MarketID"))); oRptTechMarket.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechMarket.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechMarket.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechMarket.setUsefull(cursor.getString(cursor.getColumnIndex("Useful"))); oRptTechMarket.setHarmful(cursor.getString(cursor.getColumnIndex("Harmful"))); lst.add(oRptTechMarket); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_TECH_MARKET",ex.getMessage().toString());} return null; } public SM_ReportTechMarket getReportTechMarketById(String MarketID) { try { String mSql=String.format("Select A.* from SM_REPORT_TECH_MARKET A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID "+ " where A.MarketID='%s' order by B.ReportDay desc",MarketID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportTechMarket oRptTechMarket = new SM_ReportTechMarket(); if (cursor.moveToFirst()) { do { oRptTechMarket.setMarketId(cursor.getString(cursor.getColumnIndex("MarketID"))); oRptTechMarket.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechMarket.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechMarket.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechMarket.setUsefull(cursor.getString(cursor.getColumnIndex("Useful"))); oRptTechMarket.setHarmful(cursor.getString(cursor.getColumnIndex("Harmful"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptTechMarket; }catch (Exception ex){ Log.d("ERR_LOAD_TECH_MARKET",ex.getMessage().toString()); } return null; } public String addReportTechMarket(SM_ReportTechMarket oRptTechMarket){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String MarketID=getReportTechMarketID(oRptTechMarket.getReportTechId()); if(MarketID!=""){ if(oRptTechMarket.getMarketId().isEmpty()|| oRptTechMarket.getMarketId()==null){ oRptTechMarket.setMarketId(MarketID); } } iSq=getSizeReportTechMarket(oRptTechMarket.getMarketId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("MarketID", oRptTechMarket.getMarketId()); values.put("ReportTechID", oRptTechMarket.getReportTechId()); values.put("Title", oRptTechMarket.getTitle()); values.put("Notes", oRptTechMarket.getNotes()); values.put("Useful", oRptTechMarket.getUsefull()); values.put("Harmful", oRptTechMarket.getHarmful()); db.insert("SM_REPORT_TECH_MARKET", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportTechID", oRptTechMarket.getReportTechId()); values.put("Title", oRptTechMarket.getTitle()); values.put("Notes", oRptTechMarket.getNotes()); values.put("Useful", oRptTechMarket.getUsefull()); values.put("Harmful", oRptTechMarket.getHarmful()); db.update("SM_REPORT_TECH_MARKET",values,"MarketID=?" ,new String[] {String.valueOf(oRptTechMarket.getMarketId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT TECH THI TRUONG */ /* REPORT TECH DỊCH BỆNH */ private String getReportTechDiseaseID(String ReportTechID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_TECH_DISEASE A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID WHERE B.ReportTechID=? ", new String[]{ReportTechID}); String DiseaseID=""; if (cursor.moveToFirst()) { do { DiseaseID=cursor.getString(cursor.getColumnIndex("DiseaseID")); break; } while (cursor.moveToNext()); } cursor.close(); return DiseaseID; }catch(Exception ex){return "";} } public int getSizeReportTechDisease(String DiseaseID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH_DISEASE WHERE DiseaseID=?", new String[]{DiseaseID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportTechDisease(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_TECH_DISEASE where ReportTechID in(select ReportTechID from SM_REPORT_TECH where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportTechDisease> getAllReportTechDisease(String mReportTechId) { try { List<SM_ReportTechDisease> lst = new ArrayList<SM_ReportTechDisease>(); String mSql=String.format("Select A.* from SM_REPORT_TECH_DISEASE A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID"+ " where A.ReportTechID='%s' order by B.ReportDay desc", mReportTechId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportTechDisease oRptTechDisease = new SM_ReportTechDisease(); oRptTechDisease.setDiseaseId(cursor.getString(cursor.getColumnIndex("DiseaseID"))); oRptTechDisease.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechDisease.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oRptTechDisease.setStagesCode(cursor.getString(cursor.getColumnIndex("StagesCode"))); oRptTechDisease.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechDisease.setAcreage(cursor.getFloat(cursor.getColumnIndex("Acreage"))); oRptTechDisease.setDisease(cursor.getString(cursor.getColumnIndex("Disease"))); oRptTechDisease.setPrice(cursor.getFloat(cursor.getColumnIndex("Price"))); oRptTechDisease.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); lst.add(oRptTechDisease); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_TECH_DISEASE",ex.getMessage().toString());} return null; } public SM_ReportTechDisease getReportTechDiseaseById(String DiseaseID) { try { String mSql=String.format("Select A.* from SM_REPORT_TECH_DISEASE A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID "+ " where A.DiseaseID='%s' order by B.ReportDay desc",DiseaseID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportTechDisease oRptTechDisease = new SM_ReportTechDisease(); if (cursor.moveToFirst()) { do { oRptTechDisease.setDiseaseId(cursor.getString(cursor.getColumnIndex("DiseaseID"))); oRptTechDisease.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechDisease.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oRptTechDisease.setStagesCode(cursor.getString(cursor.getColumnIndex("StagesCode"))); oRptTechDisease.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechDisease.setAcreage(cursor.getFloat(cursor.getColumnIndex("Acreage"))); oRptTechDisease.setDisease(cursor.getString(cursor.getColumnIndex("Disease"))); oRptTechDisease.setPrice(cursor.getFloat(cursor.getColumnIndex("Price"))); oRptTechDisease.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptTechDisease; }catch (Exception ex){ Log.d("ERR_LOAD_TECH_DISEASE",ex.getMessage().toString()); } return null; } public String addReportTechDisease(SM_ReportTechDisease oRptTechDisease){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String DiseaseID=getReportTechDiseaseID(oRptTechDisease.getReportTechId()); if(DiseaseID!=""){ if(oRptTechDisease.getDiseaseId().isEmpty()|| oRptTechDisease.getDiseaseId()==null){ oRptTechDisease.setDiseaseId(DiseaseID); } } iSq=getSizeReportTechDisease(oRptTechDisease.getDiseaseId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("DiseaseID", oRptTechDisease.getDiseaseId()); values.put("ReportTechID", oRptTechDisease.getReportTechId()); values.put("TreeCode", oRptTechDisease.getTreeCode()); values.put("StagesCode", oRptTechDisease.getStagesCode()); values.put("Title", oRptTechDisease.getTitle()); values.put("Acreage", oRptTechDisease.getAcreage()); values.put("Disease", oRptTechDisease.getDisease()); values.put("Price", oRptTechDisease.getPrice()); values.put("Notes", oRptTechDisease.getNotes()); db.insert("SM_REPORT_TECH_DISEASE", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportTechID", oRptTechDisease.getReportTechId()); values.put("TreeCode", oRptTechDisease.getTreeCode()); values.put("StagesCode", oRptTechDisease.getStagesCode()); values.put("Title", oRptTechDisease.getTitle()); values.put("Acreage", oRptTechDisease.getAcreage()); values.put("Disease", oRptTechDisease.getDisease()); values.put("Price", oRptTechDisease.getPrice()); values.put("Notes", oRptTechDisease.getNotes()); db.update("SM_REPORT_TECH_DISEASE",values,"DiseaseID=?" ,new String[] {String.valueOf(oRptTechDisease.getDiseaseId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT TECH DỊCH BỆNH */ /* REPORT TECH ĐỐI THỦ */ private String getReportTechCompetitorID(String ReportTechID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_TECH_COMPETITOR A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID WHERE B.ReportTechID=? ", new String[]{ReportTechID}); String CompetitorID=""; if (cursor.moveToFirst()) { do { CompetitorID=cursor.getString(cursor.getColumnIndex("CompetitorID")); break; } while (cursor.moveToNext()); } cursor.close(); return CompetitorID; }catch(Exception ex){return "";} } public int getSizeReportTechCompetitor(String CompetitorID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH_COMPETITOR WHERE CompetitorID=?", new String[]{CompetitorID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportTechCompetitor(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_TECH_COMPETITOR where ReportTechID in(select ReportTechID from SM_REPORT_TECH where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportTechCompetitor> getAllReportTechCompetitor(String mReportTechId) { try { List<SM_ReportTechCompetitor> lst = new ArrayList<SM_ReportTechCompetitor>(); String mSql=String.format("Select A.* from SM_REPORT_TECH_COMPETITOR A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID"+ " where A.ReportTechID='%s' order by B.ReportDay desc", mReportTechId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportTechCompetitor oRptTechCompetitor = new SM_ReportTechCompetitor(); oRptTechCompetitor.setCompetitorId(cursor.getString(cursor.getColumnIndex("CompetitorID"))); oRptTechCompetitor.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechCompetitor.setCompetitorPic(cursor.getString(cursor.getColumnIndex("CompetitorPic"))); oRptTechCompetitor.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechCompetitor.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechCompetitor.setUseful(cursor.getString(cursor.getColumnIndex("Useful"))); oRptTechCompetitor.setHarmful(cursor.getString(cursor.getColumnIndex("Harmful"))); lst.add(oRptTechCompetitor); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_TECHCOMPETITOR",ex.getMessage().toString());} return null; } public SM_ReportTechCompetitor getReportTechCompetitorById(String CompetitorID) { try { String mSql=String.format("Select A.* from SM_REPORT_TECH_COMPETITOR A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID "+ " where A.DiseaseID='%s' order by B.ReportDay desc",CompetitorID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportTechCompetitor oRptTechCompetitor = new SM_ReportTechCompetitor(); if (cursor.moveToFirst()) { do { oRptTechCompetitor.setCompetitorId(cursor.getString(cursor.getColumnIndex("CompetitorID"))); oRptTechCompetitor.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechCompetitor.setCompetitorPic(cursor.getString(cursor.getColumnIndex("CompetitorPic"))); oRptTechCompetitor.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechCompetitor.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechCompetitor.setUseful(cursor.getString(cursor.getColumnIndex("Useful"))); oRptTechCompetitor.setHarmful(cursor.getString(cursor.getColumnIndex("Harmful"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptTechCompetitor; }catch (Exception ex){ Log.d("ERR_LOAD_TECHCOMPETITOR",ex.getMessage().toString()); } return null; } public String addReportTechCompetitor(SM_ReportTechCompetitor oRptTechCompetotitor){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String CompetitorID=getReportTechCompetitorID(oRptTechCompetotitor.getReportTechId()); if(CompetitorID!=""){ if(oRptTechCompetotitor.getCompetitorId().isEmpty()|| oRptTechCompetotitor.getCompetitorId()==null){ oRptTechCompetotitor.setCompetitorId(CompetitorID); } } iSq=getSizeReportTechCompetitor(oRptTechCompetotitor.getCompetitorId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("CompetitorID", oRptTechCompetotitor.getCompetitorId()); values.put("ReportTechID", oRptTechCompetotitor.getReportTechId()); values.put("CompetitorPic", oRptTechCompetotitor.getCompetitorPic()); values.put("Title", oRptTechCompetotitor.getTitle()); values.put("Notes", oRptTechCompetotitor.getNotes()); values.put("Useful", oRptTechCompetotitor.getUseful()); values.put("Harmful", oRptTechCompetotitor.getHarmful()); db.insert("SM_REPORT_TECH_COMPETITOR", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportTechID", oRptTechCompetotitor.getReportTechId()); values.put("CompetitorPic", oRptTechCompetotitor.getCompetitorPic()); values.put("Title", oRptTechCompetotitor.getTitle()); values.put("Notes", oRptTechCompetotitor.getNotes()); values.put("Useful", oRptTechCompetotitor.getUseful()); values.put("Harmful", oRptTechCompetotitor.getHarmful()); db.update("SM_REPORT_TECH_COMPETITOR",values,"CompetitorID=?" ,new String[] {String.valueOf(oRptTechCompetotitor.getCompetitorId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT TECH ĐỐI THỦ */ /* REPORT TECH HOẠT ĐỘNG */ private String getReportTechActivityID(String ReportTechID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_TECH_ACTIVITIE A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID WHERE B.ReportTechID=? ", new String[]{ReportTechID}); String ActivitieID=""; if (cursor.moveToFirst()) { do { ActivitieID=cursor.getString(cursor.getColumnIndex("ActivitieID")); break; } while (cursor.moveToNext()); } cursor.close(); return ActivitieID; }catch(Exception ex){return "";} } public int getSizeReportTechActivity(String ActivitieID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_TECH_ACTIVITIE WHERE ActivitieID=?", new String[]{ActivitieID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportTechActivity(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_TECH_ACTIVITIE where ReportTechID in(select ReportTechID from SM_REPORT_TECH where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportTechActivity> getAllReportTechActivity(String mReportTechId, Integer type) { try { List<SM_ReportTechActivity> lst = new ArrayList<SM_ReportTechActivity>(); String mSql=String.format("Select A.* from SM_REPORT_TECH_ACTIVITIE A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID"+ " where A.ReportTechId='%s' and A.IsType=%d order by B.ReportDay desc", mReportTechId, type); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportTechActivity oRptTechActivity = new SM_ReportTechActivity(); oRptTechActivity.setActivitieId(cursor.getString(cursor.getColumnIndex("ActivitieID"))); oRptTechActivity.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechActivity.setIsType(cursor.getInt(cursor.getColumnIndex("IsType"))); oRptTechActivity.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechActivity.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechActivity.setAchievement(cursor.getString(cursor.getColumnIndex("Achievement"))); lst.add(oRptTechActivity); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_TECH_ACTIVITY",ex.getMessage().toString());} return null; } public SM_ReportTechActivity getReportTechActivityById(String ActivitieID) { try { String mSql=String.format("Select A.* from SM_REPORT_TECH_ACTIVITIE A LEFT JOIN SM_REPORT_TECH B ON A.ReportTechID = B.ReportTechID "+ " where A.DiseaseID='%s' order by B.ReportDay desc",ActivitieID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportTechActivity oRptTechActivity = new SM_ReportTechActivity(); if (cursor.moveToFirst()) { do { oRptTechActivity.setActivitieId(cursor.getString(cursor.getColumnIndex("ActivitieID"))); oRptTechActivity.setReportTechId(cursor.getString(cursor.getColumnIndex("ReportTechID"))); oRptTechActivity.setIsType(cursor.getInt(cursor.getColumnIndex("IsType"))); oRptTechActivity.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptTechActivity.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechActivity.setAchievement(cursor.getString(cursor.getColumnIndex("Achievement"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptTechActivity; }catch (Exception ex){ Log.d("ERR_LOAD_TECH_ACTIVITY",ex.getMessage().toString()); } return null; } public String addReportTechActivity(SM_ReportTechActivity oRptTechActivity){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String ActivitieID=getReportTechActivityID(oRptTechActivity.getReportTechId()); if(ActivitieID!=""){ if(oRptTechActivity.getActivitieId().isEmpty()|| oRptTechActivity.getActivitieId()==null){ oRptTechActivity.setActivitieId(ActivitieID); } } iSq=getSizeReportTechActivity(oRptTechActivity.getActivitieId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("ActivitieID", oRptTechActivity.getActivitieId()); values.put("ReportTechID", oRptTechActivity.getReportTechId()); values.put("IsType", oRptTechActivity.getIsType()); values.put("Title", oRptTechActivity.getTitle()); values.put("Notes", oRptTechActivity.getNotes()); values.put("Achievement", oRptTechActivity.getAchievement()); db.insert("SM_REPORT_TECH_ACTIVITIE", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportTechID", oRptTechActivity.getReportTechId()); values.put("IsType", oRptTechActivity.getIsType()); values.put("Title", oRptTechActivity.getTitle()); values.put("Notes", oRptTechActivity.getNotes()); values.put("Achievement", oRptTechActivity.getAchievement()); db.update("SM_REPORT_TECH_ACTIVITIE",values,"ActivitieID=?" ,new String[] {String.valueOf(oRptTechActivity.getActivitieId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT TECH HOẠT ĐỘNG */ public boolean delReportTech(String mReportTechId){ try { SQLiteDatabase db = getWritableDatabase(); String mSqlReportTech=String.format("delete from SM_REPORT_TECH where ReportTechID ='%s'",mReportTechId); String mSqlMarket=String.format("delete from SM_REPORT_TECH_MARKET where ReportTechID ='%s'",mReportTechId); String mSqlDisease=String.format("delete from SM_REPORT_TECH_DISEASE where ReportTechID ='%s'",mReportTechId); String mSqlCompetitor=String.format("delete from SM_REPORT_TECH_COMPETITOR where ReportTechID ='%s'",mReportTechId); String mSqlActivity=String.format("delete from SM_REPORT_TECH_ACTIVITIE where ReportTechID ='%s'",mReportTechId); try { db.execSQL(mSqlReportTech); db.execSQL(mSqlMarket); db.execSQL(mSqlDisease); db.execSQL(mSqlCompetitor); db.execSQL(mSqlActivity); }catch (Exception ex){ Log.d("DEL_SM_ODT",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } public boolean delReportTechDetail(String mReportTechId){ try { SQLiteDatabase db = getWritableDatabase(); String mSqlMarket=String.format("delete from SM_REPORT_TECH_MARKET where ReportTechID ='%s'",mReportTechId); String mSqlDisease=String.format("delete from SM_REPORT_TECH_DISEASE where ReportTechID ='%s'",mReportTechId); String mSqlCompetitor=String.format("delete from SM_REPORT_TECH_COMPETITOR where ReportTechID ='%s'",mReportTechId); String mSqlActivity=String.format("delete from SM_REPORT_TECH_ACTIVITIE where ReportTechID ='%s'",mReportTechId); try { db.execSQL(mSqlMarket); db.execSQL(mSqlDisease); db.execSQL(mSqlCompetitor); db.execSQL(mSqlActivity); }catch (Exception ex){ Log.d("DEL_SM_ODT",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } public List<DM_Tree_Disease> getListTreeDiseaseByTreeCode(String treeCode) { try { List<DM_Tree_Disease> lst = new ArrayList<>(); String mSql=String.format("Select A.* from DM_TREE_DISEASE A LEFT JOIN DM_TREE B ON A.TreeID = B.TreeID"+ " where B.TreeCode='%s' ", treeCode); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { DM_Tree_Disease oTreeDisease = new DM_Tree_Disease(); oTreeDisease.setDiseaseID(cursor.getInt(cursor.getColumnIndex("DiseaseID"))); oTreeDisease.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oTreeDisease.setDiseaseCode(cursor.getString(cursor.getColumnIndex("DiseaseCode"))); oTreeDisease.setDiseaseName(cursor.getString(cursor.getColumnIndex("DiseaseName"))); lst.add(oTreeDisease); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){ Log.d("GET_TREE_DISEASES",ex.getMessage()); } return null; } public List<DM_TreeStages> getListTreeStagesByTreeId(int TreeID) { try { List<DM_TreeStages> lst = new ArrayList<>(); String mSql=String.format("Select A.* from DM_TREE_STAGES A"+ " where A.TreeID='%d' ", TreeID ); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { DM_TreeStages oTreeStages = new DM_TreeStages(); oTreeStages.setStagesId(cursor.getInt(cursor.getColumnIndex("StagesID"))); oTreeStages.setTreeId(cursor.getInt(cursor.getColumnIndex("TreeID"))); oTreeStages.setStagesCode(cursor.getString(cursor.getColumnIndex("StagesCode"))); oTreeStages.setStagesName(cursor.getString(cursor.getColumnIndex("StagesName"))); lst.add(oTreeStages); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){ Log.d("GET_TREE_STAGE",ex.getMessage()); } return null; } public DM_Tree getTreeByCode(String treeCode) { try { String mSql=String.format("Select A.* from DM_TREE A where A.TreeCode='%s' ", treeCode); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); DM_Tree oTree = new DM_Tree(); if (cursor.moveToFirst()) { do { oTree.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oTree.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oTree.setTreeGroupCode(cursor.getString(cursor.getColumnIndex("TreeGroupCode"))); oTree.setTreeName(cursor.getString(cursor.getColumnIndex("TreeName"))); }while (cursor.moveToNext()); } cursor.close(); db.close(); return oTree; }catch (Exception ex){ Log.d("GET_TREE", ex.getMessage()); } return null; } public List<DM_Tree_Disease> getTreeDiseasesByCode(String[] DiseaseCode) { try { if(DiseaseCode.length < 0){ return null; } String lstCode = ""; for(int i = 0; i < DiseaseCode.length; i++){ if(i > 0){ lstCode += ","; } lstCode += String.format("'%s'",DiseaseCode[i]); } String mSql=String.format("Select * from DM_TREE_DISEASE where DiseaseCode in (%s)", lstCode); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); List<DM_Tree_Disease> lst = new ArrayList<DM_Tree_Disease>(); if (cursor.moveToFirst()) { do { DM_Tree_Disease oTreeDisease = new DM_Tree_Disease(); oTreeDisease.setDiseaseID(cursor.getInt(cursor.getColumnIndex("DiseaseID"))); oTreeDisease.setTreeID(cursor.getInt(cursor.getColumnIndex("TreeID"))); oTreeDisease.setDiseaseCode(cursor.getString(cursor.getColumnIndex("DiseaseCode"))); oTreeDisease.setDiseaseName(cursor.getString(cursor.getColumnIndex("DiseaseName"))); lst.add(oTreeDisease); }while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){ Log.d("GET_TREE_DISEASE", ex.getMessage()); } return null; } /* REPORT SALE REP */ private String getReportSaleRepId(String ReportDate){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_SALEREP WHERE (julianday(ReportDay)-julianday('%s')=0) ", new String[]{ReportDate}); String ReportSaleRepId=""; if (cursor.moveToFirst()) { do { ReportSaleRepId=cursor.getString(cursor.getColumnIndex("ReportSaleID")); break; } while (cursor.moveToNext()); } cursor.close(); return ReportSaleRepId; }catch(Exception ex){return "";} } public int getSizeReportSaleRep(String ReportSaleID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_SALEREP WHERE ReportSaleID=?", new String[]{ReportSaleID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportSaleRep(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_SALEREP where ReportSaleID in(select ReportSaleID from SM_REPORT_SALEREP where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); mSql = String.format("delete from SM_REPORT_SALEREP where julianday('now')-julianday(ReportDay)>%s", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportSaleRep> getAllReportSaleRep(String fday, String tDay) { try { List<SM_ReportSaleRep> lst = new ArrayList<SM_ReportSaleRep>(); String mSql=String.format("Select A.* from SM_REPORT_SALEREP A"+ " where (julianday(A.ReportDay)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.ReportDay)) >=0 order by A.ReportDay desc",fday,tDay); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportSaleRep oRptSaleRep = new SM_ReportSaleRep(); oRptSaleRep.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleRep.setReportCode(cursor.getString(cursor.getColumnIndex("ReportCode"))); oRptSaleRep.setReportName(cursor.getString(cursor.getColumnIndex("ReportName"))); oRptSaleRep.setReportDay(cursor.getString(cursor.getColumnIndex("ReportDay"))); oRptSaleRep.setLongtitude(cursor.getFloat(cursor.getColumnIndex("Longitude"))); oRptSaleRep.setLatitude(cursor.getFloat(cursor.getColumnIndex("Latitude"))); oRptSaleRep.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oRptSaleRep.setReceiverList(cursor.getString(cursor.getColumnIndex("ReceiverList"))); oRptSaleRep.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); Integer isStatus = cursor.getInt(cursor.getColumnIndex("IsStatus")); oRptSaleRep.setIsStatus(isStatus); if(isStatus != null){ if(isStatus==0)oRptSaleRep.setIsStatusDesc("Phiếu mới"); else if(isStatus==1) oRptSaleRep.setIsStatusDesc("Đã điều chỉnh"); else if(isStatus==3) oRptSaleRep.setIsStatusDesc("Đã hủy"); else oRptSaleRep.setIsStatusDesc(""); } String isPost = cursor.getString(cursor.getColumnIndex("IsPost")); if(isPost.equalsIgnoreCase("1")) { oRptSaleRep.setPost(true); }else{ oRptSaleRep.setPost(false); } oRptSaleRep.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); lst.add(oRptSaleRep); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SALE_REP",ex.getMessage().toString());} return null; } public SM_ReportSaleRep getReportSaleRepById(String reportSaleId) { try { String mSql=String.format("Select A.* from SM_REPORT_SALEREP A "+ " where A.ReportSaleID='%s' order by ReportDay desc",reportSaleId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportSaleRep oRptSaleRep = new SM_ReportSaleRep(); if (cursor.moveToFirst()) { do { oRptSaleRep.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleRep.setReportCode(cursor.getString(cursor.getColumnIndex("ReportCode"))); oRptSaleRep.setReportName(cursor.getString(cursor.getColumnIndex("ReportName"))); oRptSaleRep.setReportDay(cursor.getString(cursor.getColumnIndex("ReportDay"))); oRptSaleRep.setLongtitude(cursor.getFloat(cursor.getColumnIndex("Longitude"))); oRptSaleRep.setLatitude(cursor.getFloat(cursor.getColumnIndex("Latitude"))); oRptSaleRep.setLocationAddress(cursor.getString(cursor.getColumnIndex("LocationAddress"))); oRptSaleRep.setReceiverList(cursor.getString(cursor.getColumnIndex("ReceiverList"))); oRptSaleRep.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); Integer isStatus = cursor.getInt(cursor.getColumnIndex("IsStatus")); oRptSaleRep.setIsStatus(isStatus); if(isStatus != null){ if(isStatus==0)oRptSaleRep.setIsStatusDesc("Phiếu mới"); else if(isStatus==1) oRptSaleRep.setIsStatusDesc("Đã điều chỉnh"); else if(isStatus==3) oRptSaleRep.setIsStatusDesc("Đã hủy"); else oRptSaleRep.setIsStatusDesc(""); } String isPost = cursor.getString(cursor.getColumnIndex("IsPost")); if(isPost.equalsIgnoreCase("1")) { oRptSaleRep.setPost(true); }else{ oRptSaleRep.setPost(false); } oRptSaleRep.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptSaleRep; }catch (Exception ex){ Log.d("ERR_LOAD_SALE_REP",ex.getMessage().toString()); } return null; } public boolean editReportSale(SM_ReportSaleRep oRptSaleRep){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("ReportCode", oRptSaleRep.getReportCode()); values.put("ReportName", oRptSaleRep.getReportName()); values.put("ReportDay", oRptSaleRep.getReportDay()); values.put("Longitude", oRptSaleRep.getLongtitude()); values.put("Latitude", oRptSaleRep.getLatitude()); values.put("LocationAddress", oRptSaleRep.getLocationAddress()); values.put("ReceiverList", oRptSaleRep.getReceiverList()); values.put("Notes", oRptSaleRep.getNotes()); values.put("IsStatus", oRptSaleRep.getIsStatus()); values.put("IsPost", oRptSaleRep.getPost()); values.put("PostDay", oRptSaleRep.getPostDay()); db.update("SM_REPORT_SALEREP",values,"ReportSaleID=?" ,new String[] {String.valueOf(oRptSaleRep.getReportSaleId())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_RPT_SALE_ERR",e.getMessage()); return false;} } public String addReportSaleRep(SM_ReportSaleRep oRptSaleRep){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String ReportID=getReportSaleRepId(oRptSaleRep.getReportDay()); if(ReportID!=""){ if(oRptSaleRep.getReportSaleId().isEmpty()|| oRptSaleRep.getReportSaleId()==null){ oRptSaleRep.setReportSaleId(ReportID); } } iSq=getSizeReportSaleRep(oRptSaleRep.getReportSaleId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("ReportSaleID", oRptSaleRep.getReportSaleId()); values.put("ReportCode", oRptSaleRep.getReportCode()); values.put("ReportName", oRptSaleRep.getReportName()); values.put("ReportDay", oRptSaleRep.getReportDay()); values.put("Longitude", oRptSaleRep.getLongtitude()); values.put("Latitude", oRptSaleRep.getLatitude()); values.put("LocationAddress", oRptSaleRep.getLocationAddress()); values.put("ReceiverList", oRptSaleRep.getReceiverList()); values.put("Notes", oRptSaleRep.getNotes()); values.put("IsStatus", oRptSaleRep.getIsStatus()); values.put("IsPost", oRptSaleRep.getPost()); values.put("PostDay", oRptSaleRep.getPostDay()); db.insert("SM_REPORT_SALEREP", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportCode", oRptSaleRep.getReportCode()); values.put("ReportName", oRptSaleRep.getReportName()); values.put("ReportDay", oRptSaleRep.getReportDay()); values.put("Longitude", oRptSaleRep.getLongtitude()); values.put("Latitude", oRptSaleRep.getLatitude()); values.put("LocationAddress", oRptSaleRep.getLocationAddress()); values.put("ReceiverList", oRptSaleRep.getReceiverList()); values.put("Notes", oRptSaleRep.getNotes()); values.put("IsStatus", oRptSaleRep.getIsStatus()); values.put("IsPost", oRptSaleRep.getPost()); values.put("PostDay", oRptSaleRep.getPostDay()); db.update("SM_REPORT_SALEREP",values,"ReportSaleID=?" ,new String[] {String.valueOf(oRptSaleRep.getReportSaleId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /*END REPORT SALE REP*/ /* REPORT SALE REP THỊ TRƯỜNG */ private String getReportSaleRepMarketID(String ReportSaleID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_SALEREP_MARKET A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID WHERE B.ReportSaleID=? ", new String[]{ReportSaleID}); String MarketID=""; if (cursor.moveToFirst()) { do { MarketID=cursor.getString(cursor.getColumnIndex("MarketID")); break; } while (cursor.moveToNext()); } cursor.close(); return MarketID; }catch(Exception ex){return "";} } public int getSizeReportSaleRepMarket(String MarketID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_SALEREP_MARKET WHERE MarketID=?", new String[]{MarketID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportSaleRepMarket(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_SALEREP_MARKET where ReportSaleID in(select ReportSaleID from SM_REPORT_SALEREP where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportSaleRepMarket> getAllReportSaleRepMarket(String mReportSaleId) { try { List<SM_ReportSaleRepMarket> lst = new ArrayList<SM_ReportSaleRepMarket>(); String mSql=String.format("Select A.* from SM_REPORT_SALEREP_MARKET A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID"+ " where A.ReportSaleID='%s' order by B.ReportDay desc", mReportSaleId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportSaleRepMarket oRptSaleMarket = new SM_ReportSaleRepMarket(); oRptSaleMarket.setMarketId(cursor.getString(cursor.getColumnIndex("MarketID"))); oRptSaleMarket.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleMarket.setCustomerId(cursor.getString(cursor.getColumnIndex("CustomerID"))); oRptSaleMarket.setCompanyName(cursor.getString(cursor.getColumnIndex("CompanyName"))); oRptSaleMarket.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oRptSaleMarket.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptSaleMarket.setPrice(cursor.getFloat(cursor.getColumnIndex("Price"))); lst.add(oRptSaleMarket); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SALE_MARKET",ex.getMessage().toString());} return null; } public SM_ReportSaleRepMarket getReportSaleRepMarketById(String MarketID) { try { String mSql=String.format("Select A.* from SM_REPORT_SALEREP_MARKET A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID "+ " where A.MarketID='%s' order by B.ReportDay desc",MarketID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportSaleRepMarket oRptSalehMarket = new SM_ReportSaleRepMarket(); if (cursor.moveToFirst()) { do { oRptSalehMarket.setMarketId(cursor.getString(cursor.getColumnIndex("MarketID"))); oRptSalehMarket.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSalehMarket.setCustomerId(cursor.getString(cursor.getColumnIndex("CustomerID"))); oRptSalehMarket.setCompanyName(cursor.getString(cursor.getColumnIndex("CompanyName"))); oRptSalehMarket.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); oRptSalehMarket.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptSalehMarket.setPrice(cursor.getFloat(cursor.getColumnIndex("Price"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptSalehMarket; }catch (Exception ex){ Log.d("ERR_LOAD_SALE_MARKET",ex.getMessage().toString()); } return null; } public String addReportSaleRepMarket(SM_ReportSaleRepMarket oRptSaleMarket){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String MarketID=getReportSaleRepMarketID(oRptSaleMarket.getReportSaleId()); if(MarketID!=""){ if(oRptSaleMarket.getMarketId().isEmpty()|| oRptSaleMarket.getMarketId()==null){ oRptSaleMarket.setMarketId(MarketID); } } iSq=getSizeReportSaleRepMarket(oRptSaleMarket.getMarketId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("MarketID", oRptSaleMarket.getMarketId()); values.put("ReportSaleID", oRptSaleMarket.getReportSaleId()); values.put("CustomerID", oRptSaleMarket.getCustomerId()); values.put("CompanyName", oRptSaleMarket.getCompanyName()); values.put("ProductCode", oRptSaleMarket.getProductCode()); values.put("Notes", oRptSaleMarket.getNotes()); values.put("Price", oRptSaleMarket.getPrice()); db.insert("SM_REPORT_SALEREP_MARKET", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportSaleID", oRptSaleMarket.getReportSaleId()); values.put("CustomerID", oRptSaleMarket.getCustomerId()); values.put("CompanyName", oRptSaleMarket.getCompanyName()); values.put("ProductCode", oRptSaleMarket.getProductCode()); values.put("Notes", oRptSaleMarket.getNotes()); values.put("Price", oRptSaleMarket.getPrice()); db.update("SM_REPORT_SALEREP_MARKET",values,"MarketID=?" ,new String[] {String.valueOf(oRptSaleMarket.getMarketId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* REPORT SALE REP MÙA VỤ */ private String getReportSaleRepSeasonID(String ReportSaleID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_SALEREP_SEASON A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID WHERE B.ReportSaleID=? ", new String[]{ReportSaleID}); String DiseaseID=""; if (cursor.moveToFirst()) { do { DiseaseID=cursor.getString(cursor.getColumnIndex("SeasonID")); break; } while (cursor.moveToNext()); } cursor.close(); return DiseaseID; }catch(Exception ex){return "";} } public int getSizeReportSaleRepSeason(String SeasonID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_SALEREP_SEASON WHERE SeasonID=?", new String[]{SeasonID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportSaleRepSeason(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_SALEREP_SEASON where ReportSaleID in(select ReportSaleID from SM_REPORT_SALEREP where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportSaleRepSeason> getAllReportSaleRepSeason(String ReportSaleID) { try { List<SM_ReportSaleRepSeason> lst = new ArrayList<SM_ReportSaleRepSeason>(); String mSql=String.format("Select A.* from SM_REPORT_SALEREP_SEASON A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID"+ " where A.ReportSaleID='%s' order by B.ReportDay desc", ReportSaleID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportSaleRepSeason oRptSaleRepSeason = new SM_ReportSaleRepSeason(); oRptSaleRepSeason.setSeasonId(cursor.getString(cursor.getColumnIndex("SeasonID"))); oRptSaleRepSeason.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleRepSeason.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oRptSaleRepSeason.setSeasonCode(cursor.getString(cursor.getColumnIndex("SeasonCode"))); oRptSaleRepSeason.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptSaleRepSeason.setAcreage(cursor.getFloat(cursor.getColumnIndex("Acreage"))); oRptSaleRepSeason.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); lst.add(oRptSaleRepSeason); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SALE_SEASON",ex.getMessage().toString());} return null; } public SM_ReportSaleRepSeason getReportSaleRepSeasonById(String SeasonID) { try { String mSql=String.format("Select A.* from SM_REPORT_SALEREP_SEASON A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID "+ " where A.SeasonID='%s' order by B.ReportDay desc",SeasonID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportSaleRepSeason oRptSaleRepSeason = new SM_ReportSaleRepSeason(); if (cursor.moveToFirst()) { do { oRptSaleRepSeason.setSeasonId(cursor.getString(cursor.getColumnIndex("SeasonID"))); oRptSaleRepSeason.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleRepSeason.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oRptSaleRepSeason.setSeasonCode(cursor.getString(cursor.getColumnIndex("SeasonCode"))); oRptSaleRepSeason.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptSaleRepSeason.setAcreage(cursor.getFloat(cursor.getColumnIndex("Acreage"))); oRptSaleRepSeason.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptSaleRepSeason; }catch (Exception ex){ Log.d("ERR_LOAD_SALE_SEASON",ex.getMessage().toString()); } return null; } public String addReportSaleRepSeason(SM_ReportSaleRepSeason oRptTechSeason){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String seasonID=getReportSaleRepSeasonID(oRptTechSeason.getReportSaleId()); if(seasonID!=""){ if(oRptTechSeason.getSeasonId().isEmpty()|| oRptTechSeason.getSeasonId()==null){ oRptTechSeason.setSeasonId(seasonID); } } iSq=getSizeReportSaleRepSeason(oRptTechSeason.getSeasonId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("SeasonID", oRptTechSeason.getSeasonId()); values.put("ReportSaleID", oRptTechSeason.getReportSaleId()); values.put("TreeCode", oRptTechSeason.getTreeCode()); values.put("SeasonCode", oRptTechSeason.getSeasonCode()); values.put("Title", oRptTechSeason.getTitle()); values.put("Acreage", oRptTechSeason.getAcreage()); values.put("Notes", oRptTechSeason.getNotes()); db.insert("SM_REPORT_SALEREP_SEASON", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportSaleID", oRptTechSeason.getReportSaleId()); values.put("TreeCode", oRptTechSeason.getTreeCode()); values.put("SeasonCode", oRptTechSeason.getSeasonCode()); values.put("Title", oRptTechSeason.getTitle()); values.put("Acreage", oRptTechSeason.getAcreage()); values.put("Notes", oRptTechSeason.getNotes()); db.update("SM_REPORT_SALEREP_SEASON",values,"SeasonID=?" ,new String[] {String.valueOf(oRptTechSeason.getSeasonId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT SALE REP SEASON */ /* REPORT SALE REP DỊCH BỆNH */ private String getReportSaleRepDiseaseID(String ReportSaleID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_SALEREP_DISEASE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID WHERE B.ReportSaleID=? ", new String[]{ReportSaleID}); String DiseaseID=""; if (cursor.moveToFirst()) { do { DiseaseID=cursor.getString(cursor.getColumnIndex("DiseaseID")); break; } while (cursor.moveToNext()); } cursor.close(); return DiseaseID; }catch(Exception ex){return "";} } public int getSizeReportSaleRepDisease(String DiseaseID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_SALEREP_DISEASE WHERE DiseaseID=?", new String[]{DiseaseID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportSaleRepDisease(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_SALEREP_DISEASE where ReportSaleID in(select ReportSaleID from SM_REPORT_SALEREP where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportSaleRepDisease> getAllReportSaleRepDisease(String ReportSaleID) { try { List<SM_ReportSaleRepDisease> lst = new ArrayList<SM_ReportSaleRepDisease>(); String mSql=String.format("Select A.* from SM_REPORT_SALEREP_DISEASE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID"+ " where A.ReportSaleID='%s' order by B.ReportDay desc", ReportSaleID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportSaleRepDisease oRptSaleRepDisease = new SM_ReportSaleRepDisease(); oRptSaleRepDisease.setDiseaseId(cursor.getString(cursor.getColumnIndex("DiseaseID"))); oRptSaleRepDisease.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleRepDisease.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oRptSaleRepDisease.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptSaleRepDisease.setArceage(cursor.getFloat(cursor.getColumnIndex("Acreage"))); oRptSaleRepDisease.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); lst.add(oRptSaleRepDisease); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SALE_DISEASE",ex.getMessage().toString());} return null; } public SM_ReportSaleRepDisease getReportSaleRepDiseaseById(String DiseaseID) { try { String mSql=String.format("Select A.* from SM_REPORT_SALEREP_DISEASE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID "+ " where A.DiseaseID='%s' order by B.ReportDay desc",DiseaseID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportSaleRepDisease oRptSaleRepDisease = new SM_ReportSaleRepDisease(); if (cursor.moveToFirst()) { do { oRptSaleRepDisease.setDiseaseId(cursor.getString(cursor.getColumnIndex("DiseaseID"))); oRptSaleRepDisease.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptSaleRepDisease.setTreeCode(cursor.getString(cursor.getColumnIndex("TreeCode"))); oRptSaleRepDisease.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRptSaleRepDisease.setArceage(cursor.getFloat(cursor.getColumnIndex("Acreage"))); oRptSaleRepDisease.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRptSaleRepDisease; }catch (Exception ex){ Log.d("ERR_LOAD_SALE_DISEASE",ex.getMessage().toString()); } return null; } public String addReportSaleRepDisease(SM_ReportSaleRepDisease oRptTechDisease){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String DiseaseID=getReportSaleRepDiseaseID(oRptTechDisease.getReportSaleId()); if(DiseaseID!=""){ if(oRptTechDisease.getDiseaseId().isEmpty()|| oRptTechDisease.getDiseaseId()==null){ oRptTechDisease.setDiseaseId(DiseaseID); } } iSq=getSizeReportSaleRepDisease(oRptTechDisease.getDiseaseId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("DiseaseID", oRptTechDisease.getDiseaseId()); values.put("ReportSaleID", oRptTechDisease.getReportSaleId()); values.put("TreeCode", oRptTechDisease.getTreeCode()); values.put("Title", oRptTechDisease.getTitle()); values.put("Acreage", oRptTechDisease.getArceage()); values.put("Notes", oRptTechDisease.getNotes()); db.insert("SM_REPORT_SALEREP_DISEASE", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportSaleID", oRptTechDisease.getReportSaleId()); values.put("TreeCode", oRptTechDisease.getTreeCode()); values.put("Title", oRptTechDisease.getTitle()); values.put("Acreage", oRptTechDisease.getArceage()); values.put("Notes", oRptTechDisease.getNotes()); db.update("SM_REPORT_SALEREP_DISEASE",values,"DiseaseID=?" ,new String[] {String.valueOf(oRptTechDisease.getDiseaseId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } /* END REPORT SALE REP DICH BENH */ /* REPORT SALE REP HOAT DONG */ private String getReportSaleRepActivityID(String ReportSaleID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_REPORT_SALEREP_ACTIVITIE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID WHERE B.ReportSaleID=? ", new String[]{ReportSaleID}); String DiseaseID=""; if (cursor.moveToFirst()) { do { DiseaseID=cursor.getString(cursor.getColumnIndex("ActivitieID")); break; } while (cursor.moveToNext()); } cursor.close(); return DiseaseID; }catch(Exception ex){return "";} } public int getSizeReportSaleRepActivity(String ActivitieID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_REPORT_SALEREP_ACTIVITIE WHERE ActivitieID=?", new String[]{ActivitieID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanReportSaleRepActivity(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_REPORT_SALEREP_ACTIVITIE where ReportSaleID in(select ReportSaleID from SM_REPORT_SALEREP where julianday('now')-julianday(ReportDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_ReportSaleRepActivitie> getAllReportSaleRepAcitivity(String ActivitieID) { try { List<SM_ReportSaleRepActivitie> lst = new ArrayList<SM_ReportSaleRepActivitie>(); String mSql=String.format("Select A.* from SM_REPORT_SALEREP_ACTIVITIE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID"+ " where A.ActivitieID='%s' order by B.ReportDay desc", ActivitieID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportSaleRepActivitie oRpt = new SM_ReportSaleRepActivitie(); oRpt.setActivitieId(cursor.getString(cursor.getColumnIndex("ActivitieID"))); oRpt.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRpt.setIsType(cursor.getString(cursor.getColumnIndex("IsType"))); oRpt.setWorkDay(cursor.getString(cursor.getColumnIndex("Workday"))); oRpt.setPlace(cursor.getString(cursor.getColumnIndex("Place"))); oRpt.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRpt.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); lst.add(oRpt); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SALE_ACTIVITY",ex.getMessage().toString());} return null; } public SM_ReportSaleRepActivitie getReportSaleRepActivityById(String ActivitieID) { try { String mSql=String.format("Select A.* from SM_REPORT_SALEREP_ACTIVITIE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID "+ " where A.ActivitieID='%s' order by B.ReportDay desc",ActivitieID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_ReportSaleRepActivitie oRpt = new SM_ReportSaleRepActivitie(); if (cursor.moveToFirst()) { do { oRpt.setActivitieId(cursor.getString(cursor.getColumnIndex("ActivitieID"))); oRpt.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRpt.setIsType(cursor.getString(cursor.getColumnIndex("IsType"))); oRpt.setWorkDay(cursor.getString(cursor.getColumnIndex("Workday"))); oRpt.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); oRpt.setPlace(cursor.getString(cursor.getColumnIndex("Place"))); oRpt.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return oRpt; }catch (Exception ex){ Log.d("ERR_LOAD_SALE_DISEASE",ex.getMessage().toString()); } return null; } public String addReportSaleRepActivity(SM_ReportSaleRepActivitie oRpt){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String DiseaseID=getReportSaleRepActivityID(oRpt.getReportSaleId()); if(DiseaseID!=""){ if(oRpt.getActivitieId().isEmpty()|| oRpt.getActivitieId()==null){ oRpt.setActivitieId(DiseaseID); } } iSq=getSizeReportSaleRepActivity(oRpt.getActivitieId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("ActivitieID", oRpt.getActivitieId()); values.put("ReportSaleID", oRpt.getReportSaleId()); values.put("IsType", oRpt.getIsType()); values.put("Workday", oRpt.getWorkDay()); values.put("Title", oRpt.getTitle()); values.put("Place", oRpt.getPlace()); values.put("Notes", oRpt.getNotes()); db.insert("SM_REPORT_SALEREP_ACTIVITIE", null, values); }else{ ContentValues values = new ContentValues(); values.put("ReportSaleID", oRpt.getReportSaleId()); values.put("IsType", oRpt.getIsType()); values.put("Workday", oRpt.getWorkDay()); values.put("Title", oRpt.getTitle()); values.put("Place", oRpt.getPlace()); values.put("Notes", oRpt.getNotes()); db.update("SM_REPORT_SALEREP_ACTIVITIE",values,"ActivitieID=?" ,new String[] {String.valueOf(oRpt.getActivitieId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public List<SM_ReportSaleRepActivitie> getAllReportSaleRepActivity(String mReportSaleId, Integer type) { try { List<SM_ReportSaleRepActivitie> lst = new ArrayList<SM_ReportSaleRepActivitie>(); String mSql=String.format("Select A.* from SM_REPORT_SALEREP_ACTIVITIE A LEFT JOIN SM_REPORT_SALEREP B ON A.ReportSaleID = B.ReportSaleID"+ " where A.ReportSaleID='%s' and A.IsType=%d order by B.ReportDay desc", mReportSaleId, type); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_ReportSaleRepActivitie oRptTechActivity = new SM_ReportSaleRepActivitie(); oRptTechActivity.setActivitieId(cursor.getString(cursor.getColumnIndex("ActivitieID"))); oRptTechActivity.setReportSaleId(cursor.getString(cursor.getColumnIndex("ReportSaleID"))); oRptTechActivity.setIsType(cursor.getString(cursor.getColumnIndex("IsType"))); oRptTechActivity.setWorkDay(cursor.getString(cursor.getColumnIndex("Workday"))); oRptTechActivity.setPlace(cursor.getString(cursor.getColumnIndex("Place"))); oRptTechActivity.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); oRptTechActivity.setTitle(cursor.getString(cursor.getColumnIndex("Title"))); lst.add(oRptTechActivity); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SALE_ACTIVITY",ex.getMessage().toString());} return null; } /* END REPORT SALE REP HOAT DONG */ public boolean delReportSale(String ReportSaleID){ try { SQLiteDatabase db = getWritableDatabase(); String mSqlReport=String.format("delete from SM_REPORT_SALEREP where ReportSaleID ='%s'",ReportSaleID); String mSqlMarket=String.format("delete from SM_REPORT_SALEREP_MARKET where ReportSaleID ='%s'",ReportSaleID); String mSqlDisease=String.format("delete from SM_REPORT_SALEREP_DISEASE where ReportSaleID ='%s'",ReportSaleID); String mSqlCompetitor=String.format("delete from SM_REPORT_SALEREP_SEASON where ReportSaleID ='%s'",ReportSaleID); String mSqlActivity=String.format("delete from SM_REPORT_SALEREP_ACTIVITIE where ReportSaleID ='%s'",ReportSaleID); try { db.execSQL(mSqlReport); db.execSQL(mSqlMarket); db.execSQL(mSqlDisease); db.execSQL(mSqlCompetitor); db.execSQL(mSqlActivity); }catch (Exception ex){ Log.d("DEL_SM_RPTSALE",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } public boolean delReportSaleDetail(String ReportSaleID){ try { SQLiteDatabase db = getWritableDatabase(); String mSqlMarket=String.format("delete from SM_REPORT_SALEREP_MARKET where ReportSaleID ='%s'",ReportSaleID); String mSqlDisease=String.format("delete from SM_REPORT_SALEREP_DISEASE where ReportSaleID ='%s'",ReportSaleID); String mSqlCompetitor=String.format("delete from SM_REPORT_SALEREP_SEASON where ReportSaleID ='%s'",ReportSaleID); String mSqlActivity=String.format("delete from SM_REPORT_SALEREP_ACTIVITIE where ReportSaleID ='%s'",ReportSaleID); try { db.execSQL(mSqlMarket); db.execSQL(mSqlDisease); db.execSQL(mSqlCompetitor); db.execSQL(mSqlActivity); }catch (Exception ex){ Log.d("DEL_SM_ODT",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } /* END REPORT SALE REP THI TRUONG */ public List<DM_Season> getAllSeason(){ try { List<DM_Season> lst = new ArrayList<DM_Season>(); String mSql=String.format("select * from DM_SEASON"); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { DM_Season season = new DM_Season(); season.setSeasonCode(cursor.getString(cursor.getColumnIndex("SeasonCode"))); season.setSeasonName(cursor.getString(cursor.getColumnIndex("SeasonName"))); lst.add(season); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SEASON",ex.getMessage().toString());} return null; } public DM_Season getSeasonByCode(String code){ try { String mSql=String.format("select * from DM_SEASON where SeasonCode='%s'", code); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); DM_Season season = new DM_Season(); if (cursor.moveToFirst()) { do { season.setSeasonCode(cursor.getString(cursor.getColumnIndex("SeasonCode"))); season.setSeasonName(cursor.getString(cursor.getColumnIndex("SeasonName"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return season; }catch (Exception ex){Log.d("ERR_LOAD_SEASON",ex.getMessage().toString());} return null; } public boolean delSeason(){ String mSqlMarket=String.format("delete from DM_SEASON "); SQLiteDatabase db = this.getReadableDatabase(); try { db.execSQL(mSqlMarket); }catch (Exception ex){ Log.d("DEL_SM_SEASON",ex.getMessage()); return false; } return true; } public int getSizeSeason(String code){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_SEASON WHERE SeasonCode=?", new String[]{code}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public boolean addSeason(DM_Season obj){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeSeason(obj.getSeasonCode()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("SeasonID",obj.getSeasonID()); values.put("SeasonCode", obj.getSeasonCode()); values.put("SeasonName", obj.getSeasonName()); db.insert("DM_SEASON", null, values); }else{ iSq=iSq+1; ContentValues values = new ContentValues(); values.put("SeasonCode", obj.getSeasonCode()); values.put("SeasonName", obj.getSeasonName()); db.update("DM_SEASON",values,"SeasonID=?" ,new String[] { String.valueOf(obj.getSeasonID())}); } db.close(); return true; }catch (Exception e){Log.v("INS_SEASON_ERR",e.getMessage()); return false;} } // KE HOACH BAN HANG public boolean getIsStatusPlanSale(String mToday){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_PLAN_SALE WHERE IsStatus<=3",null); int iSq= cursor.getCount(); cursor.close(); if (iSq>0){return true;}else{return false;} }catch(Exception ex){return false;} } private String getPlanSaleId(String PlanDay){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_PLAN_SALE WHERE (julianday(PlanDay)-julianday('%s')=0) ", new String[]{PlanDay}); String PlanSaleId=""; if (cursor.moveToFirst()) { do { PlanSaleId=cursor.getString(cursor.getColumnIndex("PlanDay")); break; } while (cursor.moveToNext()); } cursor.close(); return PlanSaleId; }catch(Exception ex){return "";} } public int getSizePlanSale(String PlanID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_PLAN_SALE WHERE PlanID=?", new String[]{PlanID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanPlanSale(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_PLAN_SALE where PlanID in(select PlanID from SM_PLAN_SALE where julianday('now')-julianday(PlanDay)>%s)", iIntervalDay); db.execSQL(mSql); mSql = String.format("delete from SM_PLAN_SALE where julianday('now')-julianday(PlanDay)>%s", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_PlanSale> getAllPlanSale(String fday, String tDay) { try { List<SM_PlanSale> lst = new ArrayList<SM_PlanSale>(); String mSql=String.format("Select A.* from SM_PLAN_SALE A"+ " where (julianday(A.PlanDay)-julianday('%s')) >=0 and (julianday('%s')-julianday(A.PlanDay)) >=0 order by A.PlanDay desc",fday,tDay); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_PlanSale planSale = new SM_PlanSale(); planSale.setPlanId(cursor.getString(cursor.getColumnIndex("PlanID"))); planSale.setPlanCode(cursor.getString(cursor.getColumnIndex("PlanCode"))); planSale.setPlanDay(cursor.getString(cursor.getColumnIndex("PlanDay"))); planSale.setStartDay(cursor.getString(cursor.getColumnIndex("StartDay"))); planSale.setEndDay(cursor.getString(cursor.getColumnIndex("EndDay"))); planSale.setPlanName(cursor.getString(cursor.getColumnIndex("PlanName"))); planSale.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); planSale.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); planSale.setIsStatus(cursor.getInt(cursor.getColumnIndex("IsStatus"))); String isPost = cursor.getString(cursor.getColumnIndex("IsPost")); if(isPost.equalsIgnoreCase("1")) { planSale.setPost(true); }else{ planSale.setPost(false); } planSale.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); lst.add(planSale); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_SM_PLANSALE",ex.getMessage().toString());} return null; } public SM_PlanSale getPlanSale(String PlanID) { try { String mSql=String.format("Select A.* from SM_PLAN_SALE A where A.PlanID='%s' order by PlanDay desc",PlanID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_PlanSale planSale = new SM_PlanSale(); if (cursor.moveToFirst()) { do { planSale.setPlanId(cursor.getString(cursor.getColumnIndex("PlanID"))); planSale.setPlanCode(cursor.getString(cursor.getColumnIndex("PlanCode"))); planSale.setPlanDay(cursor.getString(cursor.getColumnIndex("PlanDay"))); planSale.setStartDay(cursor.getString(cursor.getColumnIndex("StartDay"))); planSale.setEndDay(cursor.getString(cursor.getColumnIndex("EndDay"))); planSale.setPlanName(cursor.getString(cursor.getColumnIndex("PlanName"))); planSale.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); planSale.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); planSale.setIsStatus(cursor.getInt(cursor.getColumnIndex("IsStatus"))); String isPost = cursor.getString(cursor.getColumnIndex("IsPost")); if(isPost.equalsIgnoreCase("1")) { planSale.setPost(true); }else{ planSale.setPost(false); } planSale.setPostDay(cursor.getString(cursor.getColumnIndex("PostDay"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return planSale; }catch (Exception ex){ Log.d("ERR_LOAD_SM_PAY",ex.getMessage().toString()); } return null; } public boolean editPlanSale(SM_PlanSale salePlan){ try { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("PlanCode", salePlan.getPlanCode()); values.put("PlanDay", salePlan.getPlanDay()); values.put("StartDay", salePlan.getStartDay()); values.put("EndDay", salePlan.getEndDay()); values.put("PlanName", salePlan.getPlanName()); values.put("PostDay", salePlan.getPostDay()); values.put("IsPost", salePlan.getPost()); values.put("IsStatus", salePlan.getIsStatus()); values.put("Notes", salePlan.getNotes()); db.update("SM_PLAN_SALE",values,"PlanID=?" ,new String[] {String.valueOf(salePlan.getPlanId())}); db.close(); return true; }catch (Exception e){Log.v("UDP_SM_SALE_PLAN_ERR",e.getMessage()); return false;} } public String addPlanSale(SM_PlanSale salePlan){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String PlanID=getPlanSaleId(salePlan.getPlanId()); if(PlanID!=""){ if(salePlan.getPlanId().isEmpty()|| salePlan.getPlanId()==null){ salePlan.setPlanId(PlanID); } } iSq=getSizePlanSale(salePlan.getPlanId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("PlanID", salePlan.getPlanId()); values.put("PlanCode", salePlan.getPlanCode()); values.put("PlanDay", salePlan.getPlanDay()); values.put("StartDay", salePlan.getStartDay()); values.put("EndDay", salePlan.getEndDay()); values.put("PlanName", salePlan.getPlanName()); values.put("PostDay", salePlan.getPostDay()); values.put("IsPost", salePlan.getPost()); values.put("IsStatus", salePlan.getIsStatus()); values.put("Notes", salePlan.getNotes()); db.insert("SM_PLAN_SALE", null, values); }else{ ContentValues values = new ContentValues(); values.put("PlanCode", salePlan.getPlanCode()); values.put("PlanDay", salePlan.getPlanDay()); values.put("StartDay", salePlan.getStartDay()); values.put("EndDay", salePlan.getEndDay()); values.put("PlanName", salePlan.getPlanName()); values.put("PostDay", salePlan.getPostDay()); values.put("IsPost", salePlan.getPost()); values.put("IsStatus", salePlan.getIsStatus()); values.put("Notes", salePlan.getNotes()); db.update("SM_PLAN_SALE",values,"PlanID=?" ,new String[] {String.valueOf(salePlan.getPlanId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } private String getPlanSaleDetailID(String PlanID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT A.* FROM SM_PLAN_SALE_DETAIL A LEFT JOIN SM_PLAN_SALE B ON A.PlanID = B.PlanID WHERE B.PlanID=? ", new String[]{PlanID}); String PlanDetailID=""; if (cursor.moveToFirst()) { do { PlanDetailID=cursor.getString(cursor.getColumnIndex("PlanDetailID")); break; } while (cursor.moveToNext()); } cursor.close(); return PlanDetailID; }catch(Exception ex){return "";} } public int getSizePlanSaleDetail(String PlanDetailID){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM SM_PLAN_SALE_DETAIL WHERE PlanDetailID=?", new String[]{PlanDetailID}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public void CleanPlanSaleDetail(int iIntervalDay) { try { SQLiteDatabase db = getWritableDatabase(); String mSql = String.format("delete from SM_PLAN_SALE_DETAIL where PlanID in(select PlanID from SM_PLAN_SALE where julianday('now')-julianday(PlanDay)>%s)", iIntervalDay); db.execSQL(mSql); } catch (Exception ex) { } } public List<SM_PlanSaleDetail> getAllPlanSaleDetail(String PlanID) { try { List<SM_PlanSaleDetail> lst = new ArrayList<SM_PlanSaleDetail>(); String mSql=String.format("Select A.*,C.CustomerCode,C.CustomerName, D.ProductName,D.Unit,D.Spec "+ " from SM_PLAN_SALE_DETAIL A LEFT JOIN SM_PLAN_SALE B ON A.PlanID = B.PlanID "+ " LEFT JOIN DM_CUSTOMER C ON A.CustomerID=C.CustomerID "+ " LEFT JOIN DM_PRODUCT D ON A.ProductCode=D.ProductCode where A.PlanID='%s' order by B.PlanDay desc", PlanID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { SM_PlanSaleDetail detail = new SM_PlanSaleDetail(); detail.setPlanDetailId(cursor.getString(cursor.getColumnIndex("PlanDetailID"))); detail.setPlanId(cursor.getString(cursor.getColumnIndex("PlanID"))); detail.setCustomerId(cursor.getString(cursor.getColumnIndex("CustomerID"))); detail.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); detail.setAmountBox(cursor.getDouble(cursor.getColumnIndex("AmountBox"))); detail.setAmount(cursor.getDouble(cursor.getColumnIndex("Amount"))); detail.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); detail.setNotes2(cursor.getString(cursor.getColumnIndex("Notes2"))); detail.setCustomerCode(cursor.getString(cursor.getColumnIndex("CustomerCode"))); detail.setCustomerName(cursor.getString(cursor.getColumnIndex("CustomerName"))); detail.setProductName(cursor.getString(cursor.getColumnIndex("ProductName"))); detail.setUnit(cursor.getString(cursor.getColumnIndex("Unit"))); detail.setSpec(cursor.getString(cursor.getColumnIndex("Spec"))); lst.add(detail); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_PLAN_SALE_DTL",ex.getMessage().toString());} return null; } public SM_PlanSaleDetail getPlanSaleDetailById(String PlanDetailID) { try { String mSql=String.format("Select A.* from SM_PLAN_SALE_DETAIL A LEFT JOIN SM_PLAN_SALE B ON A.PlanID = B.PlanID "+ " where A.PlanDetailID='%s' order by B.PlanDay desc",PlanDetailID); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); SM_PlanSaleDetail detail = new SM_PlanSaleDetail(); if (cursor.moveToFirst()) { do { detail.setPlanDetailId(cursor.getString(cursor.getColumnIndex("PlanDetailID"))); detail.setPlanId(cursor.getString(cursor.getColumnIndex("PlanID"))); detail.setCustomerId(cursor.getString(cursor.getColumnIndex("CustomerID"))); detail.setProductCode(cursor.getString(cursor.getColumnIndex("ProductCode"))); detail.setAmountBox(cursor.getDouble(cursor.getColumnIndex("AmountBox"))); detail.setAmount(cursor.getDouble(cursor.getColumnIndex("Amount"))); detail.setNotes(cursor.getString(cursor.getColumnIndex("Notes"))); detail.setNotes2(cursor.getString(cursor.getColumnIndex("Notes2"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return detail; }catch (Exception ex){ Log.d("ERR_LOAD_PLAN_SALE_DTL",ex.getMessage().toString()); } return null; } public String addSalePlanDetail(SM_PlanSaleDetail salePlan){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; String PlanDetailID=getPlanSaleDetailID(salePlan.getPlanDetailId()); if(PlanDetailID!=""){ if(salePlan.getPlanDetailId()==null || (salePlan.getPlanDetailId().isEmpty())){ salePlan.setPlanDetailId(PlanDetailID); } } iSq=getSizePlanSaleDetail(salePlan.getPlanDetailId()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("PlanDetailID", salePlan.getPlanDetailId()); values.put("PlanID", salePlan.getPlanId()); values.put("CustomerID", salePlan.getCustomerId()); values.put("ProductCode", salePlan.getProductCode()); values.put("AmountBox", salePlan.getAmountBox()); values.put("Amount", salePlan.getAmount()); values.put("Notes", salePlan.getNotes()); values.put("Notes2", salePlan.getNotes2()); db.insert("SM_PLAN_SALE_DETAIL", null, values); }else{ ContentValues values = new ContentValues(); values.put("PlanID", salePlan.getPlanId()); values.put("CustomerID", salePlan.getCustomerId()); values.put("ProductCode", salePlan.getProductCode()); values.put("AmountBox", salePlan.getAmountBox()); values.put("Amount", salePlan.getAmount()); values.put("Notes", salePlan.getNotes()); values.put("Notes2", salePlan.getNotes2()); db.update("SM_PLAN_SALE_DETAIL",values,"PlanDetailID=?" ,new String[] {String.valueOf(salePlan.getPlanDetailId())}); } db.close(); return ""; }catch (Exception e){ return "ERR:"+e.getMessage(); } } public boolean delPlanSale(String PlanID){ try { SQLiteDatabase db = getWritableDatabase(); String mSqlPlanSale=String.format("delete from SM_PLAN_SALE where PlanID ='%s'",PlanID); String mSqlDetail=String.format("delete from SM_PLAN_SALE_DETAIL where PlanID ='%s'",PlanID); try { db.execSQL(mSqlPlanSale); db.execSQL(mSqlDetail); }catch (Exception ex){ Log.d("DEL_SM_PLAN_SALE",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } public boolean delPlanSaleDetail(String PlanID){ try { SQLiteDatabase db = getWritableDatabase(); String mSqlDetail=String.format("delete from SM_PLAN_SALE_DETAIL where PlanID ='%s'",PlanID); try { db.execSQL(mSqlDetail); }catch (Exception ex){ Log.d("DEL_SM_PLAN_SALE_DTL",ex.getMessage()); return false; } return true; }catch (Exception ex){return false;} } public List<DM_Employee> getEmpByListId(String[] id) { try { String mId = ""; if(id != null && id.length > 0){ for(int i = 0;i < id.length; i++){ if(i > 0) mId += ","; mId += String.format("'%s'", id[i]) ; } } else { return new ArrayList<DM_Employee>(); } List<DM_Employee> lst = new ArrayList<DM_Employee>(); String mSql=String.format("Select A.* from DM_EMPLOYEE A where A.Employeeid in (%s)", mId); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { DM_Employee emp = new DM_Employee(); emp.setEmployeeid(cursor.getString(cursor.getColumnIndex("Employeeid"))); emp.setEmployeeCode(cursor.getString(cursor.getColumnIndex("EmployeeCode"))); emp.setEmployeeName(cursor.getString(cursor.getColumnIndex("EmployeeName"))); lst.add(emp); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_EMP",ex.getMessage().toString());} return null; } public List<DM_TreeStages> getAllTreeStages(){ try { List<DM_TreeStages> lst = new ArrayList<DM_TreeStages>(); String mSql=String.format("select * from DM_TREE_STAGES"); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); if (cursor.moveToFirst()) { do { DM_TreeStages treeStages = new DM_TreeStages(); treeStages.setStagesId(cursor.getInt(cursor.getColumnIndex("StagesID"))); treeStages.setTreeId(cursor.getInt(cursor.getColumnIndex("TreeID"))); treeStages.setStagesCode(cursor.getString(cursor.getColumnIndex("StagesCode"))); treeStages.setStagesName(cursor.getString(cursor.getColumnIndex("StagesName"))); lst.add(treeStages); } while (cursor.moveToNext()); } cursor.close(); db.close(); return lst; }catch (Exception ex){Log.d("ERR_LOAD_TREESTAGES",ex.getMessage().toString());} return null; } public DM_TreeStages getTreeStagesByCode(String code){ try { String mSql=String.format("select * from DM_TREE_STAGES where StagesCode='%s'", code); SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(mSql, null); DM_TreeStages treeStages = new DM_TreeStages(); if (cursor.moveToFirst()) { do { treeStages.setStagesId(cursor.getInt(cursor.getColumnIndex("StagesID"))); treeStages.setTreeId(cursor.getInt(cursor.getColumnIndex("TreeID"))); treeStages.setStagesCode(cursor.getString(cursor.getColumnIndex("StagesCode"))); treeStages.setStagesName(cursor.getString(cursor.getColumnIndex("StagesName"))); } while (cursor.moveToNext()); } cursor.close(); db.close(); return treeStages; }catch (Exception ex){Log.d("ERR_GET_TREESTAGES",ex.getMessage().toString());} return null; } public boolean delTreeStages(){ String mSql=String.format("delete from DM_TREE_STAGES "); SQLiteDatabase db = this.getReadableDatabase(); try { db.execSQL(mSql); }catch (Exception ex){ Log.d("DEL_DM_TREE_STAGES",ex.getMessage()); return false; } return true; } public int getSizeTreeStages(String code){ try { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery("SELECT * FROM DM_TREE_STAGES WHERE StagesCode=?", new String[]{code}); int iSq= cursor.getCount(); cursor.close(); return iSq; }catch(Exception ex){return -1;} } public boolean addTreeStages(DM_TreeStages obj){ try { SQLiteDatabase db = this.getWritableDatabase(); int iSq = 1; iSq=getSizeTreeStages(obj.getStagesName()); if (iSq<=0) { ContentValues values = new ContentValues(); values.put("StagesID",obj.getStagesId()); values.put("TreeID", obj.getTreeId()); values.put("StagesCode", obj.getStagesCode()); values.put("StagesName", obj.getStagesName()); db.insert("DM_TREE_STAGES", null, values); }else{ iSq=iSq+1; ContentValues values = new ContentValues(); values.put("TreeID", obj.getTreeId()); values.put("StagesCode", obj.getStagesCode()); values.put("StagesName", obj.getStagesName()); db.update("DM_TREE_STAGES",values,"StagesID=?" ,new String[] { String.valueOf(obj.getStagesId())}); } db.close(); return true; }catch (Exception e){Log.v("INS_TREESTAGES_ERR",e.getMessage()); return false;} } //<<SYSTEM-FUNCTION>> public String fFormatNgay(String ngay, String sFormatFrom, String sFormatTo){ if (ngay==null || ngay.contains("null") || ngay.equals("")) return sFormatFrom=="yyyy-MM-dd"?"01/01/1900":"1900-01-01"; String sCastNgay=""; try{ Date date = new SimpleDateFormat(sFormatFrom).parse(ngay); sCastNgay = new SimpleDateFormat(sFormatTo).format(date); return sCastNgay; }catch (Exception ex){return (sFormatFrom=="yyyy-MM-dd"?"01/01/1900":"1900-01-01");} } //<<END>> }
package com.google.android.exoplayer2.h; import java.util.Collections; import java.util.HashMap; import java.util.Map; public final class q$f { private final Map<String, String> aBE = new HashMap(); private Map<String, String> aBF; public final synchronized Map<String, String> lX() { if (this.aBF == null) { this.aBF = Collections.unmodifiableMap(new HashMap(this.aBE)); } return this.aBF; } }
package com.studio.saradey.aplicationvk.model.view.couter; import com.studio.saradey.aplicationvk.model.Comments; /** * @author jtgn on 08.08.2018 */ public class CommentCounterViewModel extends CounterViewModel { private Comments mComments; public CommentCounterViewModel(Comments comments) { super(comments.getCount()); this.mComments = comments; } public Comments getComments() { return mComments; } }
import java.util.ArrayList; public class CalculationManager { private String calculation = "0"; private CalculationListener listener; public void addCalculationListener(CalculationListener listener) { this.listener = listener; listener.updateCalculation(); } public String getCalculation() { return calculation; } public void addCharacter(String character) { calculation = (calculation == "0" && character != "." && character != "+" && character != "-" && character != "x" && character != "/" ) ? character : calculation + character; listener.updateCalculation(); } public void deleteLastCharacter() { calculation = calculation.length() > 1 ? calculation.substring(0, calculation.length() - 1) : "0"; listener.updateCalculation(); } public void clear() { calculation = "0"; listener.updateCalculation(); } public void calculate() { ArrayList<String> blocks = new ArrayList<String>(); String currentBlock = ""; try { for(int i = 0; i < calculation.length(); i++) { char currentCharacter = calculation.charAt(i); if(currentCharacter == '.') { currentBlock += currentCharacter; continue; } if(Character.isDigit(currentCharacter)) { currentBlock += Character.getNumericValue(currentCharacter); if(i == (calculation.length() - 1)) blocks.add(currentBlock); continue; } blocks.add( i == 0 ? "0" : currentBlock); if(currentCharacter == 'x') {blocks.add("x");} if(currentCharacter == '/') {blocks.add("/");} if(currentCharacter == '+') {blocks.add("+");} if(currentCharacter == '-') {blocks.add("-");} currentBlock = ""; } while(blocks.size() > 1) { for(int i = 0; i < blocks.size(); i++) { if(blocks.get(i) == "x" || blocks.get(i) == "/") { double a = Double.parseDouble(blocks.get(i - 1)); double b = Double.parseDouble(blocks.get(i + 1)); double ans = blocks.get(i) == "x" ? (a * b) : (a / b); blocks.remove(i + 1); blocks.remove(i); if(Math.floor(ans) == ans) { blocks.set(i - 1, Integer.toString((int)ans)); continue; } blocks.set(i - 1, Double.toString(ans)); } } for(int i = 0; i < blocks.size(); i++) { if(blocks.get(i) == "+" || blocks.get(i) == "-") { double a = Double.parseDouble(blocks.get(i - 1)); double b = Double.parseDouble(blocks.get(i + 1)); double ans = blocks.get(i) == "+" ? (a + b) : (a - b); blocks.remove(i + 1); blocks.remove(i); if(Math.floor(ans) == ans) { blocks.set(i - 1, Integer.toString((int)ans)); continue; } blocks.set(i - 1, Double.toString(ans)); } } } if(Double.parseDouble(blocks.get(0)) == 2147483647) { calculation = "Error: Cannot divide by zero"; listener.updateCalculation(); calculation = "0"; return; } calculation = blocks.get(0); listener.updateCalculation(); } catch(Exception e) { calculation = "Error: Invalid input"; System.err.println("Caught exception: " + e); listener.updateCalculation(); calculation = "0"; } } }
package com.davemorrissey.labs.subscaleview.view; import android.os.Handler.Callback; import android.os.Message; class SubsamplingScaleImageView$2 implements Callback { final /* synthetic */ SubsamplingScaleImageView abb; SubsamplingScaleImageView$2(SubsamplingScaleImageView subsamplingScaleImageView) { this.abb = subsamplingScaleImageView; } public final boolean handleMessage(Message message) { if (message.what == 1 && SubsamplingScaleImageView.b(this.abb) != null) { SubsamplingScaleImageView.c(this.abb); SubsamplingScaleImageView.a(this.abb, SubsamplingScaleImageView.b(this.abb)); this.abb.performLongClick(); SubsamplingScaleImageView.d(this.abb); } return true; } }
package com.example.android_advanced_01; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import org.xmlpull.v1.XmlPullParser; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = (ListView) findViewById(R.id.listView); ArrayList<String> list = new ArrayList<>(); try { XmlPullParser parser = getResources().getXml(R.xml.candies); while (parser.getEventType() != XmlPullParser.END_DOCUMENT) { if (parser.getEventType() == XmlPullParser.START_TAG && parser.getName().equals("candy")) { list.add(parser.getAttributeValue(0)); } parser.next(); } } catch (Throwable t) { Toast.makeText(this, "Ошибка при загрузке XML-документа: " + t.toString(), Toast.LENGTH_LONG) .show(); } ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list); listView.setAdapter(adapter); } }