Browse Source

商品配方

master
fyf 1 year ago
parent
commit
f42e17dfea
13 changed files with 795 additions and 227 deletions
  1. +2
    -2
      app/src/main/AndroidManifest.xml
  2. +40
    -4
      app/src/main/java/com/example/bpa/db/QueryDB.java
  3. +95
    -0
      app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java
  4. +16
    -2
      app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java
  5. +0
    -10
      app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java
  6. +227
    -0
      app/src/main/java/com/example/bpa/view/from/add_pf_activity.java
  7. +0
    -187
      app/src/main/java/com/example/bpa/view/from/spgl_activity.java
  8. +104
    -4
      app/src/main/java/com/example/bpa/view/from/yfpf_activity.java
  9. +11
    -0
      app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java
  10. +102
    -0
      app/src/main/res/layout/datatab/layout/pf_item.xml
  11. +27
    -1
      app/src/main/res/layout/datatab/layout/sp_item.xml
  12. +41
    -10
      app/src/main/res/layout/from/layout/activity_add_pf.xml
  13. +130
    -7
      app/src/main/res/layout/from/layout/activity_yfpf.xml

+ 2
- 2
app/src/main/AndroidManifest.xml View File

@@ -12,12 +12,12 @@
android:allowBackup="true"
android:icon="@mipmap/ncd"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="false"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true"
tools:targetApi="31">
<activity
android:name=".view.from.spgl_activity"
android:name=".view.from.add_pf_activity"
android:exported="false" />
<activity
android:name=".view.from.wlgl_activity"


+ 40
- 4
app/src/main/java/com/example/bpa/db/QueryDB.java View File

@@ -23,6 +23,7 @@ import com.example.bpa.db.mode.BPA_SYSTEMSET;
import com.example.bpa.db.mode.BPA_USER;
import com.example.bpa.db.mode.ModeBase;
import com.example.bpa.helper.Tools;
import com.example.bpa.view.mode.ResGoodsRecipe;
import com.example.bpa.view.mode.ResSilosMode;

import java.lang.reflect.Field;
@@ -521,18 +522,53 @@ public class QueryDB {
* @param id
* @return
*/
public static ArrayList<BPA_GOODSRECIPE> GetGoodsSrecipeList(String id)
public static ArrayList<ResGoodsRecipe> GetGoodsSrecipeList(String id)
{
String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序
String where="isDelete=? and goodsID=?";
String[] args=new String[] { "0",id };
ArrayList<BPA_GOODSRECIPE> data=new ArrayList<>();
ArrayList<ResGoodsRecipe> data=new ArrayList<>();
ArrayList<Object> obj=Get(BPA_GOODSRECIPE.class,where,args,orderby);
for (Object k:obj) {
data.add(((BPA_GOODSRECIPE)k));
for (Object item:obj) {
BPA_GOODSRECIPE k=(BPA_GOODSRECIPE)item;
BPA_MATERIAL ma= GetMaterialID(k.materialID);
if(ma!=null)
{
ResGoodsRecipe par=new ResGoodsRecipe();
par.id=k.id;
par.createTime=k.createTime;
par.updateTime=k.updateTime;
par.deleteTime=k.deleteTime;
par.deviceID=k.deviceID;
par.userID=k.userID;
par.isDelete=k.isDelete;
par.exp=k.exp;
par.materialName=ma.name;

par.goodsID=k.goodsID;
par.materialID=k.materialID;
par.value=k.value;
par.sort=k.sort;
data.add(par);
}
}
return data;
}
/**
* 根据商品id删除配料信息
* @param id
* @return
*/
public static Boolean DeleteGoodsSrecipeList(String id)
{
if (id.isEmpty())
return false;
SQLiteDatabase db = helper.getWritableDatabase();
long delete=db.delete(BPA_GOODSRECIPE.class.getSimpleName(), "goodsID=?",
new String[] { id });
db.close();
return delete>0;
}
//endregion

//region BPA_ORDER 订单表


+ 95
- 0
app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java View File

@@ -0,0 +1,95 @@
package com.example.bpa.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.bpa.R;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.T;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.ResGoodsRecipe;

import java.util.ArrayList;
import java.util.List;

/**
* 配料数据表格
*/
public class pf_adapter extends ArrayAdapter<ResGoodsRecipe> {
/**
* 内部点击事件
*/
private MyClickListener mListener;
private List<ResGoodsRecipe> datas;

ArrayList<String> wuliao=new ArrayList<>();

public pf_adapter(@NonNull Context context, int resource, @NonNull List<ResGoodsRecipe> objects, ArrayList<BPA_MATERIAL> wl, MyClickListener listener) {
super(context, resource, objects);
mListener = listener;
datas=objects;
if(wuliao.size()<=0)
{
wuliao=new ArrayList<>();
for (BPA_MATERIAL me:wl)
{
wuliao.add(me.name);
}
}
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ResGoodsRecipe resGoodsRecipe = (ResGoodsRecipe) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(R.layout.pf_item, parent, false);
//分别获取 image view 和 textview 的实例
Spinner name = view.findViewById(R.id.name);
TextView sort = view.findViewById(R.id.sort);
TextView value = view.findViewById(R.id.value);
Button button = view.findViewById(R.id.button_item);
// 设置要显示的图片和文字
ArrayAdapter mAdapter = new android.widget.ArrayAdapter<String>(view.getContext(),
android.R.layout.simple_spinner_item);
mAdapter.addAll(wuliao);
name.setAdapter(mAdapter);

if(resGoodsRecipe.materialName!=null && !resGoodsRecipe.materialName.isEmpty())
{
SpinnerAdapter apsAdapter= name.getAdapter();
int k= apsAdapter.getCount();
for(int i=0;i<k;i++){
if(resGoodsRecipe.materialName.equals(apsAdapter.getItem(i).toString())){
name.setSelection(i,true);
break;
}
}
}
value.setText(resGoodsRecipe.value+"");
sort.setText(resGoodsRecipe.sort+"");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,resGoodsRecipe);
} catch (Exception e)
{
T.show(view.getContext(),"删除配方出错:"+e.getMessage());
}
}
});
return view;
}
}

+ 16
- 2
app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java View File

@@ -6,7 +6,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;
@@ -14,7 +13,6 @@ import androidx.annotation.Nullable;

import com.example.bpa.R;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.T;
import com.example.bpa.view.inteface.MyClickListener;

@@ -44,12 +42,16 @@ public class sp_adapter extends ArrayAdapter<BPA_GOODS> {
//分别获取 image view 和 textview 的实例
TextView name = view.findViewById(R.id.name);
TextView sort = view.findViewById(R.id.sort);
TextView time = view.findViewById(R.id.time);

Button button = view.findViewById(R.id.button_item);
Button button_up = view.findViewById(R.id.button_item_Up);
Button button_down = view.findViewById(R.id.button_item_Down);
Button button_update = view.findViewById(R.id.button_item_update);

// 设置要显示的图片和文字
name.setText(bpa_goods.name);
time.setText(bpa_goods.createTime);
sort.setText(bpa_goods.sort+"");
button.setOnClickListener(new View.OnClickListener() {
@Override
@@ -87,6 +89,18 @@ public class sp_adapter extends ArrayAdapter<BPA_GOODS> {
}
}
});
button_update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,bpa_goods);
} catch (Exception e)
{
T.show(view.getContext(),"商品修改出错:"+e.getMessage());
}
}
});
return view;
}
}

+ 0
- 10
app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java View File

@@ -2,7 +2,6 @@ package com.example.bpa.view.fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

@@ -11,14 +10,10 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.bpa.LoginActivity;
import com.example.bpa.MainActivity;
import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.helper.T;
import com.example.bpa.view.control.ItemClickListener;
import com.example.bpa.view.control.MainMeunAdapter;
@@ -27,7 +22,6 @@ import com.example.bpa.view.from.ddyjrz_activity;
import com.example.bpa.view.from.dzcjy_activity;
import com.example.bpa.view.from.lcsz_activity;
import com.example.bpa.view.from.lsjy_activity;
import com.example.bpa.view.from.spgl_activity;
import com.example.bpa.view.from.wlgl_activity;
import com.example.bpa.view.from.yfcl_activity;
import com.example.bpa.view.from.yfpf_activity;
@@ -71,7 +65,6 @@ public class SystemCapabilitiesFragment extends Fragment {

menuModes.clear();
menuModes.add(new MenuMode("物料管理",R.mipmap.wlgl));
menuModes.add(new MenuMode("商品管理",R.mipmap.spgl));
menuModes.add(new MenuMode("料仓设置",R.mipmap.lcsz));
menuModes.add(new MenuMode("电子秤校验",R.mipmap.dzcjy));
menuModes.add(new MenuMode("流速校验",R.mipmap.lsjy));
@@ -100,9 +93,6 @@ public class SystemCapabilitiesFragment extends Fragment {
case "物料管理":
intent = new Intent(view.getContext(), wlgl_activity.class);
break;
case "商品管理":
intent = new Intent(view.getContext(), spgl_activity.class);
break;
case "料仓设置":
intent = new Intent(view.getContext(), lcsz_activity.class);
break;


+ 227
- 0
app/src/main/java/com/example/bpa/view/from/add_pf_activity.java View File

@@ -0,0 +1,227 @@
package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.db.mode.BPA_GOODSRECIPE;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.Json;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.pf_adapter;
import com.example.bpa.view.adapter.sp_adapter;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.ResGoodsRecipe;

import java.util.ArrayList;

public class add_pf_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener {
//region 变量
/**
* 返回按钮
*/
ImageView gongneng_fanhui;
/**
* 标题设置
*/
TextView gongneng_title;
//endregion

//region 操作变量
/**
* 输入框
*/
TextView edittext;
/**
* 增加按钮
*/
Button buttonsave, buttonaddwuliao;
/**
* 表格显示
*/
ListView datatab;
/**
* 配方数据
*/
ArrayList<ResGoodsRecipe> bpa_pf = new ArrayList<>();
/**
* 当前传入的商品数据
*/
BPA_GOODS good = null;

/**
* 商品数据
*/
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>();
/**
* wulaipo
*/
ArrayList<BPA_MATERIAL> wuliao=new ArrayList<>();
//endregion

//region 私有函数
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_pf);
Init();
initEvents();
}
//endregion

//region 公共函数

/**
* 初始化
*/
private void Init() {
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
edittext = this.findViewById(R.id.edittext);
buttonsave = this.findViewById(R.id.buttonsave);
buttonaddwuliao = this.findViewById(R.id.buttonaddwuliao);
datatab = this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg = getIntent().getStringExtra("title");
String data = getIntent().getStringExtra("data");
if (!data.isEmpty()) {
good = new Json<BPA_GOODS>().jsonToobject(BPA_GOODS.class, data);
edittext.setText(good.name);
}
gongneng_title.setText(msg);
Initdata();
bpa_goods= QueryDB.GetGoodsALL();
wuliao=QueryDB.GetMaterialALL();
}

/**
* 初始化按钮事件
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
buttonsave.setOnClickListener(this);
buttonaddwuliao.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata() {
bpa_pf = new ArrayList<>();
try {
if (good != null)//修改
{
bpa_pf= QueryDB.GetGoodsSrecipeList(good.id);
}
} catch (Exception e) {

}
}

/**
* 刷新DataTab
*/
public void DataTab()
{
pf_adapter adapter = new pf_adapter(add_pf_activity.this, R.layout.pf_item, bpa_pf,wuliao,this);
datatab.setAdapter(adapter);
}
//endregion

//region 点击事件

/**
* 本页面点击事件监听22
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.buttonaddwuliao://新增空白行
ResGoodsRecipe recipe=new ResGoodsRecipe();
recipe.sort=bpa_pf.size()+1;
bpa_pf.add(recipe);
DataTab();
break;
case R.id.buttonsave://保存按钮点击
if(bpa_pf.size()<=0)
{
T.show(this, "配方信息不能为空!");
return;
}
if (good == null)//新增
{
String name = edittext.getText().toString();
if (name.isEmpty()) {
T.show(this, "商品名称不能为空!");
return;
}
if (QueryDB.GetGoodsIs(name)) {
T.show(this, "商品名称重复,请重新输入后重试!");
return;
}
BPA_GOODS goodx = new BPA_GOODS();
goodx.name = name;
goodx.sort = bpa_goods.size() + 1;
goodx.status = 1;
goodx.deviceID = ConfigName.getInstance().DeviceId;
goodx.userID = ConfigName.getInstance().user.userID;
QueryDB.AddGoods(goodx);
good=goodx;
}else //修改
{
QueryDB.UpdateGoods(good);
QueryDB.DeleteGoodsSrecipeList(good.id);
}

for (ResGoodsRecipe item:bpa_pf)
{
BPA_GOODSRECIPE da=new BPA_GOODSRECIPE();
da.goodsID = good.id;
da.materialID = item.materialID;
da.value = item.value;
da.sort =item.sort;
da.deviceID = ConfigName.getInstance().DeviceId;
da.userID = ConfigName.getInstance().user.userID;
QueryDB.AddGoodsSrecipe(da);
}
T.show(this, "操作成功!");
this.finish();
break;
}
}

/**
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v, Object data) {
switch (v.getId()) {
case R.id.button_item://删除
bpa_pf.remove(data);
DataTab();
break;
case R.id.button_item_Up://上移动

break;
case R.id.button_item_Down://下移动

break;
}
}
//endregion
}

+ 0
- 187
app/src/main/java/com/example/bpa/view/from/spgl_activity.java View File

@@ -1,187 +0,0 @@
package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.sp_adapter;
import com.example.bpa.view.adapter.wl_adapter;
import com.example.bpa.view.inteface.MyClickListener;

import java.util.ArrayList;

public class spgl_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener {

//region 变量
/**
* 返回按钮
*/
ImageView gongneng_fanhui;
/**
* 标题设置
*/
TextView gongneng_title;

//endregion

//region 操作变量
/**
* 输入框
*/
TextView edittext;
/**
* 增加按钮
*/
Button buttonadd;
/**
* 表格显示
*/
ListView datatab;
/**
* 商品数据
*/
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>();
//endregion

//region 私有函数
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spgl);
Init();
initEvents();
}
//endregion

//region 公共函数

/**
* 初始化
*/
private void Init(){
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
edittext= this.findViewById(R.id.edittext);
buttonadd= this.findViewById(R.id.buttonadd);
datatab= this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
gongneng_title.setText(msg);
Initdata();
}

/**
* 初始化按钮事件
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
buttonadd.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata()
{
try{
bpa_goods= QueryDB.GetGoodsALL();
sp_adapter adapter = new sp_adapter(spgl_activity.this, R.layout.sp_item, bpa_goods,this);
datatab.setAdapter(adapter);
}catch(Exception e){

}
}
//endregion

//region 点击事件
/**
* 本页面点击事件监听
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.buttonadd://增加按钮点击
String name= edittext.getText().toString();
if(name.isEmpty()){
T.show(this, "商品名称不能为空!");
return;
}
if(QueryDB.GetGoodsIs(name)){
T.show(this, "商品名称重复,请重新输入后重试!");
return;
}
BPA_GOODS good=new BPA_GOODS();
good.name=name;
good.sort=bpa_goods.size()+1;
good.status=1;
good.deviceID= ConfigName.getInstance().DeviceId;
good.userID=ConfigName.getInstance().user.userID;
QueryDB.AddGoods(good);
T.show(this, "新增成功!");
Initdata();
break;
}
}

/**
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v,Object data) {
switch (v.getId())
{
case R.id.button_item://删除按钮
int sort=((BPA_GOODS)data).sort;
String id=((BPA_GOODS)data).id;
Log.i("日志",sort + "--- "+id);
QueryDB.DeleteGoods((BPA_GOODS)data);
Initdata();
for (BPA_GOODS k:bpa_goods) {
if(k.sort>sort)
{
QueryDB.GetGoodsSort(k,1);
}
}
Initdata();
break;
case R.id.button_item_Up://上移动按钮
BPA_GOODS good=(BPA_GOODS)data;
if(good.sort==1)
{
T.show(this, "已是最顶部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,1);
Initdata();
break;
case R.id.button_item_Down://下移动按钮
BPA_GOODS good2=(BPA_GOODS)data;
if(good2.sort==bpa_goods.size())
{
T.show(this, "已是最底部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,0);
Initdata();
break;
}
}
//endregion
}

+ 104
- 4
app/src/main/java/com/example/bpa/view/from/yfpf_activity.java View File

@@ -2,17 +2,30 @@ package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.helper.Json;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.sp_adapter;
import com.example.bpa.view.inteface.MyClickListener;

import java.util.ArrayList;

/**
* 配方研发
*/
public class yfpf_activity extends AppCompatActivity implements View.OnClickListener{
public class yfpf_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener {
//region 变量
/**
* 返回按钮
@@ -24,6 +37,21 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
TextView gongneng_title;
//endregion

//region 操作变量
/**
* 增加按钮
*/
Button buttonaddpf;
/**
* 表格显示
*/
ListView datatab;
/**
* 商品数据
*/
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>();
//endregion

//region 私有函数
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -42,11 +70,12 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
private void Init(){
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
buttonaddpf=this.findViewById(R.id.buttonaddpf);
datatab= this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
gongneng_title.setText(msg);

((TextView)this.findViewById(R.id.test_view)).setText(msg);
Initdata();
}

/**
@@ -54,12 +83,27 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
buttonaddpf.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata()
{
try{
bpa_goods= QueryDB.GetGoodsALL();
sp_adapter adapter = new sp_adapter(yfpf_activity.this, R.layout.sp_item, bpa_goods,this);
datatab.setAdapter(adapter);
}catch(Exception e){

}
}
//endregion

//region 点击事件
/**
* 本页面点击事件监听
* 本页面点击事件监听22
*
* @param v
*/
@@ -69,6 +113,62 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.buttonaddpf://新建配方
Intent intent = new Intent(this, add_pf_activity.class);
intent.putExtra("title", "新建配方");
intent.putExtra("data", "");
startActivity(intent);
break;
}
}

/**
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v,Object data) {
switch (v.getId())
{
case R.id.button_item://删除按钮
int sort=((BPA_GOODS)data).sort;
String id=((BPA_GOODS)data).id;
Log.i("日志",sort + "--- "+id);
QueryDB.DeleteGoods((BPA_GOODS)data);
Initdata();
for (BPA_GOODS k:bpa_goods) {
if(k.sort>sort)
{
QueryDB.GetGoodsSort(k,1);
}
}
Initdata();
break;
case R.id.button_item_Up://上移动按钮
BPA_GOODS good=(BPA_GOODS)data;
if(good.sort==1)
{
T.show(this, "已是最顶部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,1);
Initdata();
break;
case R.id.button_item_Down://下移动按钮
BPA_GOODS good2=(BPA_GOODS)data;
if(good2.sort==bpa_goods.size())
{
T.show(this, "已是最底部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,0);
Initdata();
break;
case R.id.button_item_update://修改按钮
Intent intent = new Intent(this, add_pf_activity.class);
intent.putExtra("title", "新建配方");
intent.putExtra("data",new Json().objectToJson(BPA_GOODS.class,data));
startActivity(intent);
break;
}
}
//endregion

+ 11
- 0
app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java View File

@@ -0,0 +1,11 @@
package com.example.bpa.view.mode;

import com.example.bpa.db.mode.BPA_GOODSRECIPE;

/**
* 界面显示商品配方结构
*/
public class ResGoodsRecipe extends BPA_GOODSRECIPE {
//物料名称
public String materialName;
}

+ 102
- 0
app/src/main/res/layout/datatab/layout/pf_item.xml View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:background="@mipmap/bgxz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<Spinner
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:hint="请输入序号"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:id="@+id/sort"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:hint="请输入序号"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:hint="请输入数值"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button_item"
android:text="删除"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
</LinearLayout>

</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 27
- 1
app/src/main/res/layout/datatab/layout/sp_item.xml View File

@@ -35,7 +35,7 @@
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/sort"
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
@@ -49,6 +49,21 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/sort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="回锅肉"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -74,6 +89,17 @@
android:layout_width="60dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/button_item_update"
android:text="修改"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/button_item"
android:text="删除"


app/src/main/res/layout/from/layout/activity_spgl.xml → app/src/main/res/layout/from/layout/activity_add_pf.xml View File

@@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@mipmap/dpbj"
tools:context=".view.from.spgl_activity">
tools:context=".view.from.add_pf_activity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
@@ -93,7 +93,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="名称:"
android:text="饮料名称:"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"/>
<EditText
@@ -106,18 +106,36 @@
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:layout_marginLeft="5dp"
android:hint="请输入商品名称"
android:hint="请输入饮料名称"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/buttonadd"
android:text="新增"
android:id="@+id/buttonaddwuliao"
android:text="添加新行"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/buttonsave"
android:text="保存饮品"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_width="80dp"
android:layout_height="26dp"
/>
</LinearLayout>
@@ -165,7 +183,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="商品名称"
android:text="物料名称"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
@@ -178,10 +196,11 @@
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="序"
android:text="出料顺序"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -191,11 +210,23 @@
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="用户操作"
android:text="微调数值"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="操作"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 130
- 7
app/src/main/res/layout/from/layout/activity_yfpf.xml View File

@@ -79,13 +79,136 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/test_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foreground"
android:textSize="@dimen/TitleSize">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
</LinearLayout>
<Button
android:id="@+id/buttonaddpf"
android:layout_alignParentRight="true"
android:text="新建配方"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_marginRight="20dp"
android:layout_width="100dp"
android:layout_height="36dp"
/>
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:background="@mipmap/bgbtbj"
android:layout_height="26dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF03668F" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#FF03668F" />
<TableLayout
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="饮料名称"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="创建时间"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="排序"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="用户操作"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/datatab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="3dp"
android:layout_marginTop="3dp"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

Loading…
Cancel
Save