Ejemplo n.º 1
0
        private void LoadingData(object logion)
        {
            string ls_logion = logion == null ? "" : logion.ToString();
            ProgressBar progressBar = FindViewById<ProgressBar>(Resource.Id.Loading_progressBar1);
            TextView Msg = FindViewById<TextView>(Resource.Id.Loading_Msg);

            string name = Intent.GetStringExtra("name");
            string table = Intent.GetStringExtra("table");
            string ls_DeviceId = SysVisitor.MEID(this);
            string CompanyList = _publicfuns.of_GetMySysSet("Login", "CompanyList");
            string CompanyHost = "";// _publicfuns.of_GetMySysSet("Login", "CompanyHost");
            RunOnUiThread(() =>
            {
                Msg.Text = "正在准备刷新管理员表,请不要断开网络连接\n可能需要几分钟甚至更长时间";
            });
            if (string.IsNullOrEmpty(CompanyList) || string.IsNullOrEmpty(CompanyHost))
            {
                string ls_error = "";
                CompanyList = YW.of_GetCompanyList(ls_DeviceId);
                if (!string.IsNullOrEmpty(CompanyList))
                {
                    if (CompanyList.Substring(0, 2) == "OK")
                    {
                        //if(!string.IsNullOrEmpty(SysVisitor.Get_Comname()))//当用户有多个comname时,手动切换默认comname
                        //{
                        //    string ls_default = SysVisitor.Get_Comname();//OKERPtest,YunCai,sanrong
                        //    string comnameList = CompanyList;
                        //    comnameList = comnameList.Replace("," + ls_default, "");
                        //    comnameList = comnameList.Replace(ls_default+ ",", "");
                        //    comnameList += "," + ls_default;
                        //    CompanyList = comnameList;
                        //}
                        _publicfuns.of_SetMySysSet("Login", "CompanyList", CompanyList);
                    }
                    else
                    {
                        //RunOnUiThread(() =>
                        //{
                        //    Msg.Text = "你的手机未注册,请注册后重试" + ls_DeviceId;
                        //});
                        //return;
                        StartActivity(typeof(enroll));
                        Finish();
                        return;
                    }
                }
                else
                {
                    //RunOnUiThread(() =>
                    //{
                    //    Msg.Text = "你的手机未注册,请注册后重试/n" + ls_DeviceId;
                    //});
                    //return;
                    StartActivity(typeof(enroll));
                    Finish();
                    return;
                }
                YW.of_GetERPurl(SysVisitor.Get_Comname(), ls_DeviceId);
                ls_error = YW.of_CheckNetWorkOK();
                if (ls_error != "OK")
                {
                    RunOnUiThread(() =>
                    {
                        Msg.Text = "未能成功连接服务器,3秒后将重试";
                    });
                    Thread.Sleep(3000);
                    LoadingData(logion);
                    return;
                }
                CompanyHost = YW.of_GetCompanyHost(SysVisitor.MEID(this));
                if (CompanyHost.Substring(0, 2) == "OK")
                {
                    _publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
                }
            }
            if (CompanyHost.Substring(0, 2) == "OK")
            {
                _publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
            }

            progressBar.Max = 100;
            try
            {
                DataTable ldt_group = new DataTable();
                ldt_group = baseclass.YW.SendMessage_MygroupUser("gid,groupname", "mygroup", true);
                if (ldt_group.Rows.Count > 0)
                {
                    _Count += 50;
                    progressBar.Progress = _Count;
                    RunOnUiThread(() =>
                    {
                        Msg.Text = "已下载分组数据" + _Count + "0%";
                    });
                }
                DataTable ldt_user = new DataTable();
                ldt_user = baseclass.YW.SendMessage_MygroupUser("uid,gid,username", "myuser", true);
                string json = baseclass.Json.DataTableToJson(ldt_user);
                if (ldt_user.Rows.Count > 0)
                {
                    _Count += 50;
                    progressBar.Progress = _Count;
                    RunOnUiThread(() =>
                    {
                        Msg.Text = "已下载用户数据" + _Count + "0%";
                    });
                }
                progressBar.Progress = 0;
                RunOnUiThread(() =>
                {
                    Msg.Text = "正在导入分组数据" + 0 + "0%";
                });
                SqliteHelper.ExecuteNum("delete from mygroup");//先删除
                for (int i = 0; i < ldt_group.Rows.Count; i++)
                {
                    progressBar.Max = ldt_group.Rows.Count;
                    Core.n_create_sql lnv_sql = new Core.n_create_sql();
                    lnv_sql.of_SetTable("mygroup");
                    lnv_sql.of_AddCol("gid", ldt_group.Rows[i]["gid"]);
                    lnv_sql.of_AddCol("groupname", ldt_group.Rows[i]["groupname"]);
                    lnv_sql.of_execute();
                    progressBar.Progress = i;
                    RunOnUiThread(() =>
                    {
                        Msg.Text = "已导入分组数据" + i + "0%";
                    });
                }
                progressBar.Progress = 0;
                RunOnUiThread(() =>
                {
                    Msg.Text = "正在导入用户数据" + 0 + "%";
                });
                SqliteHelper.ExecuteNum("delete from myuser");//先删除
                for (int i = 0; i < ldt_user.Rows.Count; i++)
                {
                    progressBar.Max = ldt_user.Rows.Count;
                    Core.n_create_sql lnv_sql = new Core.n_create_sql();
                    lnv_sql.of_SetTable("myuser");
                    lnv_sql.of_AddCol("uid", ldt_user.Rows[i]["uid"]);
                    lnv_sql.of_AddCol("gid", ldt_user.Rows[i]["gid"]);
                    lnv_sql.of_AddCol("username", ldt_user.Rows[i]["username"]);
                    lnv_sql.of_execute();
                    progressBar.Progress = i;
                    RunOnUiThread(() =>
                    {
                        Msg.Text = "已导入分组数据" + i + "0%";
                    });
                }
                //业务员是否能修改价格
                string ls_sql = "select Itemvalue from mysysset where ItemType='GETORDER' and itemName='canmodifyprice'";
                string ls_canmodifyprice = SqlHelper.ExecuteScalar(ls_sql);
                if (string.IsNullOrEmpty(ls_canmodifyprice))
                {
                    _publicfuns.of_SetMySysSet("GETORDER", "canmodifyprice", "N");
                }
                if (ls_canmodifyprice == "Y")
                {
                    _publicfuns.of_SetMySysSet("GETORDER", "canmodifyprice", "Y");
                }
                else
                {
                    _publicfuns.of_SetMySysSet("GETORDER", "canmodifyprice", "N");
                }
                ls_sql = "select Itemvalue from mysysset where ItemType='COMPANY' and itemName='CompanyName'";
                string ls_CompanyName = SqlHelper.ExecuteScalar(ls_sql);
                if (!string.IsNullOrEmpty(ls_CompanyName))
                {
                    baseclass.MyConfig.of_SetMySysSet("COMPANY", "CompanyName", ls_CompanyName);
                }
                if (ls_logion == "true")
                {
                    //返回登陆页
                    Intent it = new Intent();
                    it.SetClass(this.ApplicationContext, typeof(MainActivity));
                    StartActivity(it);
                    Finish();
                }
            }
            catch (Exception e)
            {
                SysVisitor.Log("LoadingDataError", e.Message);
                RunOnUiThread(() =>
                {
                    Msg.Text = "加载数据出错,请重试";
                });
            }
        }
Ejemplo n.º 2
0
 public static bool of_SetMySysSet(string as_type, string as_item, string as_value, string as_memo)
 {
     SqliteHelper.connStr = connStr;
     int li_row = 0;
     string ls_sql = "select count(*) from mysysset where itemtype='" + as_type + "' and itemname='" + as_item + "'";
     li_row = SqliteHelper.ExecuteNum(ls_sql);
     n_create_sql lnv_sql = new n_create_sql(connStr);
     lnv_sql.of_SetTable("mysysset");
     lnv_sql.of_AddCol("itemtype", as_type);
     lnv_sql.of_AddCol("itemname", as_item);
     lnv_sql.of_AddCol("itemvalue", as_value);
     lnv_sql.of_AddCol("memo", as_memo);
     bool li_rc = false;
     if (li_row <= 0)
         li_rc = lnv_sql.of_execute();
     if (li_row > 0)
     {
         SqliteParameter[] p = new SqliteParameter[] { new SqliteParameter("@itemtype", as_type), new SqliteParameter("@itemname", as_item) };
         li_rc = lnv_sql.of_execute("itemtype=@itemtype and itemname=@itemname", p);
     }
     SqlErr = lnv_sql.SqlErr;
     SqlStr = lnv_sql.SqlStr;
     return li_rc;
 }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.backmoneyrecord);
            string ls_cus_code = SysVisitor.cus_code;
            TextView txt_cus_name = FindViewById<TextView>(Resource.Id.backmoneyrecord_cus_name);
            Spinner sp_subcom = FindViewById<Spinner>(Resource.Id.backmoneyrecord_subcom);
            Spinner sp_bank = FindViewById<Spinner>(Resource.Id.backmoneyrecord_bank);
            TextView txt_date = FindViewById<TextView>(Resource.Id.backmoneyrecord_date);
            Spinner sp_type = FindViewById<Spinner>(Resource.Id.backmoneyrecord_moneytype);
            TextView txt_money = FindViewById<TextView>(Resource.Id.backmoneyrecord_money);
            TextView txt_memo = FindViewById<TextView>(Resource.Id.backmoneyrecord_memo);
            CheckBox chk_memo = FindViewById<CheckBox>(Resource.Id.backmoneyrecord_iscustomer);
            TextView txt_fee = FindViewById<TextView>(Resource.Id.backmoneyrecord_Counter_fee);
            Button save = FindViewById<Button>(Resource.Id.backmoneyrecord_submit);
            CheckBox iscustomer = FindViewById<CheckBox>(Resource.Id.backmoneyrecord_iscustomer);
            TextView txt_give_money = FindViewById<TextView>(Resource.Id.backmoneyrecord_give_money);
            LinearLayout IBtn_back = FindViewById<LinearLayout>(Resource.Id.backmoneyrecord_cancel);
            Button sel_username= FindViewById<Button>(Resource.Id.backmoneyrecord_check_username);

            sel_username.Click += delegate 
            {
                Intent intent = new Intent();
                Bundle bu = new Bundle();
                bu.PutString("name", "backmoneyrecord");
                intent.PutExtras(bu);
                intent.SetClass(this, typeof(Customer));
                StartActivity(intent);
            };

            IBtn_back.Click += delegate 
            {
                OnBackPressed();
                //StartActivity(typeof(Index));
            };
            #region 设置客户
            if (!string.IsNullOrEmpty(ls_cus_code))
            {
                txt_cus_name.Text = SysVisitor.cus_name;
            }
            txt_cus_name.FocusChange += delegate 
            {
                if (!txt_cus_name.HasFocus)
                {
                    if (txt_cus_name.Text != "")
                    {
                        string sql = "select cus_code from customer where cus_name = '" + txt_cus_name.Text + "'";
                        ls_cus_code = SqliteHelper.ExecuteScalar(sql);
                        if (string.IsNullOrEmpty(ls_cus_code))
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(this);
                            builder.SetTitle("提示:");
                            builder.SetMessage("输入的客户不存在");
                            builder.SetNegativeButton("确定", delegate { });
                            builder.Show();
                            txt_cus_name.Text = "";
                            SysVisitor.cus_code = "";
                            return;
                        }
                        SysVisitor.cus_code = ls_cus_code;
                    }
                    else
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.SetTitle("提示:");
                        builder.SetMessage("客户名称不能为空");
                        builder.SetNegativeButton("确定", delegate { });
                        builder.Show();
                        SysVisitor.cus_code = "";
                        return;
                    }
                }
            };
            #endregion
            #region 为控件绑定数据
            txt_date.Text = DateTime.Now.ToString("yyyy-MM-dd");

            DataTable ldt_subcom = new DataTable();
            ldt_subcom = SqliteHelper.ExecuteDataTable("select comname FROM subcom");
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < ldt_subcom.Rows.Count; i++)
            {
                adapter.Add(ldt_subcom.Rows[i]["comname"].ToString());
            }
            sp_subcom.Adapter = adapter;

            DataTable ldt_type = new DataTable();
            ldt_type = SqliteHelper.ExecuteDataTable("select accname FROM accsubject where oneaccno like '101%'");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            for (int i = 0; i < ldt_type.Rows.Count; i++)
            {
                adapter.Add(ldt_type.Rows[i]["accname"].ToString());
            }
            sp_bank.Adapter = adapter;

            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
            adapter.Add("现金");
            adapter.Add("银行");
            sp_type.Adapter = adapter;
            #endregion

            sp_type.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(sp_type_ItemSelected);
            save.Click += delegate 
            {
                if (string.IsNullOrEmpty(SysVisitor.cus_code))
                {
                    Toast.MakeText(this, "请先选择客户", ToastLength.Long).Show();
                    return;
                }
                #region 获取值
                string ls_cusname = txt_cus_name.Text;
                string ls_date = txt_date.Text;
                string ls_money = txt_money.Text;
                string ls_memo = txt_memo.Text;
                bool lb_fee = iscustomer.Checked;
                string ls_fee = txt_fee.Text;
                string ls_subcom = as_subcom;
                string ls_bank = as_bank;
                string ls_type = as_type;
                string ls_give = txt_give_money.Text;
                as_bank = sp_bank.SelectedItem.ToString();
                as_subcom = sp_subcom.SelectedItem.ToString();
                as_type = sp_type.SelectedItem.ToString();
                #endregion
                #region 判断条件
                if (ls_type == "现金/银行")
                {
                    Toast.MakeText(this, "请选择汇款方式", ToastLength.Long).Show();
                    return;
                }
                if (ls_date.Length < 8)
                {
                    Toast.MakeText(this, "日期格式不对", ToastLength.Long).Show();
                    return;
                }
                if (ls_date.Split('-').Length != 3)
                {
                    Toast.MakeText(this, "日期格式不对", ToastLength.Long).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_money))
                {
                    Toast.MakeText(this, "请输入汇款金额", ToastLength.Long).Show();
                    return;
                }
                #endregion
                string bankmoneyno = SqliteHelper.ExecuteScalar("select accno FROM accsubject where accname ='" + ls_bank + "'");
                string ls_subcom_id= SqliteHelper.ExecuteScalar("select subNo FROM subcom where comname='" + ls_subcom + "'");
                string ls_id = Guid.NewGuid().ToString("N");
                n_create_sql lnv_sql = new n_create_sql();
                lnv_sql.of_SetTable("backmoneyrecord");
                lnv_sql.of_AddCol("recordno", ls_id);
                lnv_sql.of_AddCol("insdate", DateTime.Now.ToString("yyyy-MM-dd"));
                lnv_sql.of_AddCol("human", SysVisitor.UserName);
                lnv_sql.of_AddCol("cus_code", ls_cus_code);
                lnv_sql.of_AddCol("money", ls_money);
                lnv_sql.of_AddCol("subcom", ls_subcom_id);
                lnv_sql.of_AddCol("checkman", SysVisitor.UserName);
                lnv_sql.of_AddCol("checkdate", ls_date);
                lnv_sql.of_AddCol("bankmoneyno", ls_id);
                lnv_sql.of_AddCol("memo", ls_memo);
                lnv_sql.of_AddCol("bank", bankmoneyno);
                lnv_sql.of_AddCol("GiftMoney", ls_give);
                lnv_sql.of_AddCol("isupdate", "N");
                lnv_sql.of_execute();
                Toast.MakeText(this, "保存成功", ToastLength.Long).Show();
                System.Threading.Thread.Sleep(500);
                Intent it = new Intent();
                it.SetClass(this.ApplicationContext, typeof(Index));
                StartActivity(it);
            };
        }
Ejemplo n.º 4
0
        private void of_Save()
        {
            string ls_TotalAll = "", GivePrice = "";
            DataTable ldt_Goods = new DataTable();
            ldt_Goods = Of_bind_ShopCar(out ls_TotalAll, out GivePrice);

            #region 保存订单
            string ls_OrderNO = Guid.NewGuid().ToString("N");
            string ls_SettleKind = SqliteHelper.ExecuteScalar("select SettleKind from customer where cus_code='" + SysVisitor.cus_code + "'");
            EditText memo = FindViewById<EditText>(Resource.Id.OrderSave_memo);
            string ls_receiveaddr = SqliteHelper.ExecuteScalar("select trafficeAddr from customer where cus_code='" + SysVisitor.cus_code + "'");
            string ls_cusPhone = SqliteHelper.ExecuteScalar("select mobile from customer where cus_code='" + SysVisitor.cus_code + "'");
            n_create_sql lnv_sql = new n_create_sql();
            lnv_sql.of_SetTable("getmain");
            lnv_sql.of_AddCol("orderno", ls_OrderNO);
            lnv_sql.of_AddCol("haveout", "N");
            lnv_sql.of_AddCol("cus_code", SysVisitor.cus_code);
            lnv_sql.of_AddCol("cus_name", SysVisitor.cus_name);//selfno
            lnv_sql.of_AddCol("webhuman", SysVisitor.cus_name);
            lnv_sql.of_AddCol("isorder", "N");
            lnv_sql.of_AddCol("getorderdate", DateTime.Now);
            lnv_sql.of_AddCol("settlekind", ls_SettleKind);
            lnv_sql.of_AddCol("memo", memo.Text);
            lnv_sql.of_AddCol("receiveaddr", ls_receiveaddr);
            lnv_sql.of_AddCol("cusPhone", ls_cusPhone);
            lnv_sql.of_AddCol("inputMan", SysVisitor.UserName);
            lnv_sql.of_AddCol("isupdate", "N");
            lnv_sql.of_execute();
            #endregion
            #region 保存订单明细
            int li_seq = 0;
            foreach (DataRow Dr in ldt_Goods.Rows)
            {
                li_seq = li_seq + 1;
                string ls_Getdetailid = Guid.NewGuid().ToString("N");
                string ls_Goodcode = Dr["goo_code"].ToString();
                if (ls_Goodcode.Trim().Length == 0 || ls_Goodcode == "&nbsp;")
                { continue; }
                string ls_num = Dr["num"].ToString();
                try
                {
                    if (Convert.ToDecimal(ls_num) <= 0)
                    { continue; }
                }
                catch
                { continue; }
                string ls_memo = "正常";
                try
                {
                    if (Convert.ToDecimal(Dr["price"]) <= 0)
                    {
                        ls_memo = "买赠";
                    }
                }
                catch { }
                n_create_sql lnv_detail = new n_create_sql();
                lnv_detail.of_SetTable("getdetail");
                lnv_detail.of_AddCol("orderno", ls_OrderNO);
                lnv_detail.of_AddCol("goo_code", ls_Goodcode);
                lnv_detail.of_AddCol("num", ls_num);
                lnv_detail.of_AddCol("HaveSendNum", 0);
                lnv_detail.of_AddCol("havesend", "N");
                lnv_detail.of_AddCol("getdetailid", ls_Getdetailid);
                lnv_detail.of_AddCol("sequence", li_seq);
                lnv_detail.of_AddCol("memo", ls_memo);
                lnv_detail.of_AddCol("price", Dr["price"]);
                lnv_detail.of_AddCol("disbeforeprice", Dr["price"]);
                lnv_detail.of_execute();
            }
            #endregion
            Toast.MakeText(this, "订单保存成功", ToastLength.Short).Show();
            Shopping.Clear();
            System.Threading.Thread.Sleep(500);
            Intent it = new Intent();
            it.SetClass(this.ApplicationContext, typeof(Customer));
            StartActivity(it);
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.NewCustomer);

            LinearLayout cancel = FindViewById<LinearLayout>(Resource.Id.NewCustomer_cancel);
            Spinner sp_prov = FindViewById<Spinner>(Resource.Id.NewCustomer_prov);
            Spinner sp_city = FindViewById<Spinner>(Resource.Id.NewCustomer_city);
            EditText etxt_city = FindViewById<EditText>(Resource.Id.NewCustomer_newCity);
            Button btn_next = FindViewById<Button>(Resource.Id.NewCustomer_Next);
            TextView txt_title = FindViewById<TextView>(Resource.Id.NewCustomer_title);
            TextView txt_msg = FindViewById<TextView>(Resource.Id.NewCustomer_msg);
            BindProv(sp_prov);
            sp_prov.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            btn_next.Click += delegate
            {
                string ls_prov = "", ls_city = "";
                try
                {
                    ls_prov = sp_prov.SelectedItem.ToString();
                    if (ls_prov == "选择省份")
                        ls_prov = "";
                }
                catch { }
                ls_city = etxt_city.Text;
                if (ls_city == "")
                {
                    try
                    {
                        ls_city = sp_city.SelectedItem.ToString();
                    }
                    catch { }
                }
                if (ls_prov == "")
                {
                    Toast.MakeText(this, "选择的省区无效,请重新选择", ToastLength.Short).Show();
                    return;
                }
                if (ls_city == "")
                {
                    Toast.MakeText(this, "选择的城市无效,请重新选择或输入新城市", ToastLength.Short).Show();
                    return;
                }
                string ls_id = "";
                while (true)
                {
                    Random rd = new Random();
                    int li_id = rd.Next(100, 1000);
                    ls_id = "TMP" + li_id;
                    int row = SqliteHelper.ExecuteNum("select count(*) from customer where fax='" + ls_id + "'");
                    if (row < 1)
                        break;
                }
                string ls_prov_code = SqliteHelper.ExecuteScalar("select prov_code from province where prov_name='"+ ls_prov + "'");
                n_create_sql lnv_sql = new n_create_sql();
                lnv_sql.of_SetTable("customer");
                lnv_sql.of_AddCol("cus_code", ls_id);
                lnv_sql.of_AddCol("cus_name", ls_id);
                lnv_sql.of_AddCol("cus_prov", ls_prov_code);
                lnv_sql.of_AddCol("Cus_City", ls_city);
                lnv_sql.of_AddCol("linkman", SysVisitor.UserName);
                lnv_sql.of_AddCol("customercreatetime", DateTime.Now.ToString());
                lnv_sql.of_AddCol("modifydate", DateTime.Now.ToString());
                bool lbok = false;
                lbok = lnv_sql.of_execute();
                if (lbok)
                {
                    //_publicfuns.of_SetMySysSet("waitupload", "customer", ls_id, "insert");
                    SysVisitor.cus_code = ls_id;
                    System.Threading.Thread.Sleep(500);
                    StartActivity(typeof(OrderCar));
                    Finish();
                }
            };
            cancel.Click += delegate
            {
                StartActivity(typeof(OrderCar));
                Finish();
            };
        }