示例#1
0
文件: OutOne.cs 项目: eatage/GyAppMf
        private Spinner sp_subcomLocal; //开卡店

        #endregion Fields

        #region Methods

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.OutOne);

            IntentName = Intent.GetStringExtra("cardno");//卡号
            #region 初始化控件
            ibtn_cancel = FindViewById<ImageButton>(Resource.Id.OutOne_cancel);
            btn_save = FindViewById<Button>(Resource.Id.OutOne_save);
            sp_subcom = FindViewById<Spinner>(Resource.Id.OutOne_SubCom);//选择分店
            et_search = FindViewById<EditText>(Resource.Id.OutOne_Search);//搜索
            et_cusname = FindViewById<EditText>(Resource.Id.OutOne_CusName);//姓名
            sp_sex = FindViewById<Spinner>(Resource.Id.OutOne_Sex);//性别
            sp_subcomLocal = FindViewById<Spinner>(Resource.Id.OutOne_CusTypeLocal);//开卡店
            et_balance = FindViewById<EditText>(Resource.Id.OutOne_Balance);//充值余额
            sp_custype = FindViewById<Spinner>(Resource.Id.OutOne_CusType);//会员级别
            et_laststore = FindViewById<EditText>(Resource.Id.OutOne_Lastdate);//最后充值
            et_integral = FindViewById<EditText>(Resource.Id.OutOne_Integral);//现有积分
            et_discount = FindViewById<EditText>(Resource.Id.OutOne_Discount);//服务折扣
            et_memcard = FindViewById<EditText>(Resource.Id.OutOne_MemCard);//会员卡扣款
            et_customercard = FindViewById<EditText>(Resource.Id.OutOne_CustomerCard);//会员卡号
            et_ysmoney = FindViewById<EditText>(Resource.Id.OutOne_YsMoney);//应收金额
            et_ticketmoneybefore = FindViewById<EditText>(Resource.Id.OutOne_TicketMoneyBefore);//抵扣金额
            et_factmoney = FindViewById<EditText>(Resource.Id.OutOne_FactMoney);//实际应收
            et_carsh = FindViewById<EditText>(Resource.Id.OutOne_Crash);//补现金
            et_selfno = FindViewById<EditText>(Resource.Id.OutOne_Selfno);//手工单号
            et_memo = FindViewById<EditText>(Resource.Id.OutOne_Momo);//备注
            btn_Clean = FindViewById<Button>(Resource.Id.OutOne_Clean);//清除信息
            #endregion

            #region 指定不可编辑项
            et_cusname.Enabled = false;
            et_cusname.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            sp_sex.Enabled = false;
            sp_sex.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            sp_subcomLocal.Enabled = false;
            sp_subcomLocal.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_balance.Enabled = false;
            et_balance.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            sp_custype.Enabled = false;
            sp_custype.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_laststore.Enabled = false;
            et_laststore.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_integral.Enabled = false;
            et_integral.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_memcard.Enabled = false;
            et_memcard.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_customercard.Enabled = false;
            et_customercard.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            #endregion

            et_cusname.Text = "散客";

            #region Spinner控件赋值
            //性别
            Java.Lang.Object[] sex = { "请选择", "先生", "女士" };
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, sex);
            sp_sex.Adapter = adapter;
            sp_sex.SetSelection(2, true);
            //所属分店
            string[] subcom = SysVisitor.GetArryList("select subno,comname from subcom");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, subcom);
            sp_subcom.Adapter = adapter;
            //开卡店sp_subcomLocal
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, subcom);
            sp_subcomLocal.Adapter = adapter;
            //会员级别
            string[] custype = SysVisitor.GetArryList("select cardlevel, carcname from cardtype");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, custype);
            sp_custype.Adapter = adapter;
            #endregion
            if (!string.IsNullOrEmpty(IntentName))
            {
                Onbind(IntentName);
            }
            et_search.FocusChange += delegate
            {
                if (!et_search.HasFocus)
                {
                    string ls_search = et_search.Text.Trim();
                    if (!string.IsNullOrEmpty(ls_search))
                    {
                        Onbind(ls_search);
                    }

                }
            };
            //应收金额
            et_ysmoney.FocusChange += delegate
            {
                if (!et_ysmoney.HasFocus)
                {
                    if (et_ysmoney.Text.Trim() != "")
                    { CountMoney(); }
                }
            };
            //抵扣金额
            et_ticketmoneybefore.FocusChange += delegate
            {
                if (!et_ticketmoneybefore.HasFocus)
                {
                    if (et_ticketmoneybefore.Text.Trim() != "")
                    { CountMoney(); }
                }
            };
            //实际应收
            et_factmoney.FocusChange += delegate
            {
                if (!et_factmoney.HasFocus)
                {
                    if (et_factmoney.Text.Trim() != "")
                    { CountMoney(); }
                }
            };
            //补现金
            et_carsh.FocusChange += delegate
            {
                if (!et_carsh.HasFocus)
                {
                    if (et_carsh.Text.Trim() != "")
                    { CountMoney(); }
                }
            };

            btn_Clean.Click += delegate
            {
                IntentName = "";
                refresh();
            };
            //保存
            btn_save.Click += delegate
            {
                string ls_subcom = sp_subcom.SelectedItem == null ? "" : sp_subcom.SelectedItem.ToString();//所属分店
                if (ls_subcom == "请选择")
                    ls_subcom = "";
                else
                    ls_subcom = SqliteHelper.ExecuteScalar("select subno from subcom where comname='" + ls_subcom + "'");

                string ls_sex = sp_sex.SelectedItem.ToString();//性别
                if (ls_sex == "请选择")
                    ls_sex = "";
                if (ls_sex == "先生")
                    ls_sex = "Y";
                if (ls_sex == "女士")
                    ls_sex = "N";

                string ls_subcomLocal = sp_subcomLocal.SelectedItem == null ? "" : sp_subcomLocal.SelectedItem.ToString();//开卡店
                if (ls_subcomLocal == "请选择")
                    ls_subcomLocal = "";
                else
                    ls_subcomLocal = SqliteHelper.ExecuteScalar("select subno from subcom where comname='" + sp_subcomLocal + "'");

                string ls_custype = sp_custype.SelectedItem == null ? "" : sp_custype.SelectedItem.ToString();//会员级别
                if (ls_custype == "请选择")
                    ls_custype = "";
                else
                    ls_custype = SqliteHelper.ExecuteScalar("select cardlevel from cardtype where carcname='" + ls_custype + "'");

                string ls_et_cusname = et_cusname.Text;//姓名
                string ls_et_cardno = et_customercard.Text;//卡号
                string ls_et_discount = et_discount.Text;//服务折扣
                string ls_et_integral = et_integral.Text;//现有积分
                string ls_et_memcard = et_memcard.Text;//会员卡扣款
                string ls_et_ysmoney = et_ysmoney.Text;//应收金额
                string ls_et_ticketmoneybefore = et_ticketmoneybefore.Text;//抵扣金额
                string ls_et_factmoney = et_factmoney.Text;//实际应收
                string ls_et_carsh = et_carsh.Text;//补现金
                string ls_et_selfno = et_selfno.Text;//手工单号
                string ls_et_memo = et_memo.Text;//备注

                n_create_sql lnv_sql = new n_create_sql();
                lnv_sql.of_SetTable("outone");
                lnv_sql.of_AddCol("subno", ls_subcom);
                lnv_sql.of_AddCol("salecusname", ls_et_cusname);
                lnv_sql.of_AddCol("sex", ls_sex);
                lnv_sql.of_AddCol("subcom", ls_subcomLocal);
                lnv_sql.of_AddCol("ysmoney", ls_et_ysmoney);
                lnv_sql.of_AddCol("ticketmoney_before", ls_et_ticketmoneybefore);
                lnv_sql.of_AddCol("subno", ls_subcom);
                lnv_sql.of_AddCol("selfno", ls_et_selfno);
                lnv_sql.of_AddCol("factmoney", ls_et_factmoney);
                lnv_sql.of_AddCol("carsh", et_carsh);
                lnv_sql.of_AddCol("discount", ls_et_discount);
                lnv_sql.of_AddCol("memcard", ls_et_memcard);
                lnv_sql.of_AddCol("customer_card", ls_et_cardno);
                lnv_sql.of_AddCol("memo", ls_et_memo);
                bool lb_ok = false;
                lb_ok = lnv_sql.of_execute();
                if(lb_ok)
                {

                }
            };
        }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Member_Detail);

            IntentName = Intent.GetStringExtra("cardno");//卡号
            #region 注册控件
            ImageButton ibtn_cancel = FindViewById<ImageButton>(Resource.Id.Member_Detail_cancel);
            Button btn_save = FindViewById<Button>(Resource.Id.Member_Detail_save);
            EditText et_cusname = FindViewById<EditText>(Resource.Id.Member_Detail_CusName);//姓名
            Spinner sp_sex = FindViewById<Spinner>(Resource.Id.Member_Detail_Sex);//性别
            EditText et_cardno = FindViewById<EditText>(Resource.Id.Member_Detail_CardNo);//卡号
            Spinner sp_subcom = FindViewById<Spinner>(Resource.Id.Member_Detail_SubCom);//所属分店
            EditText et_mobile = FindViewById<EditText>(Resource.Id.Member_Detail_Mobile);//手机
            Spinner sp_custype = FindViewById<Spinner>(Resource.Id.Member_Detail_CusType);//会员级别
            EditText et_pwd = FindViewById<EditText>(Resource.Id.Member_Detail_Pwd);//密码
            EditText et_chkpwd = FindViewById<EditText>(Resource.Id.Member_Detail_ChkPwd);//确认密码
            EditText et_money = FindViewById<EditText>(Resource.Id.Member_Detail_Money);//余额
            EditText et_consumecyc = FindViewById<EditText>(Resource.Id.Member_Detail_Consumecyc);//消费周期
            Spinner sp_empname = FindViewById<Spinner>(Resource.Id.Member_Detail_Empname);//开卡人
            EditText et_EffectTime = FindViewById<EditText>(Resource.Id.Member_Detail_EffectTime);//有效日期
            EditText et_Birthday = FindViewById<EditText>(Resource.Id.Member_Detail_Birthday);//生日
            EditText et_Firstdate = FindViewById<EditText>(Resource.Id.Member_Detail_Firstdate);//首次来店
            EditText et_Address = FindViewById<EditText>(Resource.Id.Member_Detail_Address);//地址
            EditText et_lastdate = FindViewById<EditText>(Resource.Id.Member_Detail_Lastdate);//最后来店
            EditText et_memo = FindViewById<EditText>(Resource.Id.Member_Detail_Memo);//备注
            EditText et_Feature1 = FindViewById<EditText>(Resource.Id.Member_Detail_Feature1);//会员特征1
            EditText et_Feature2 = FindViewById<EditText>(Resource.Id.Member_Detail_Feature2);//会员特征2
            EditText et_Comname = FindViewById<EditText>(Resource.Id.Member_Detail_Comname);//公司
            EditText et_Phone = FindViewById<EditText>(Resource.Id.Member_Detail_Phone);//固定电话
            EditText et_Fan = FindViewById<EditText>(Resource.Id.Member_Detail_Fan);//IC卡号
            EditText et_Email = FindViewById<EditText>(Resource.Id.Member_Detail_Email);//Email
            EditText et_Appenddate = FindViewById<EditText>(Resource.Id.Member_Detail_Appenddate);//录入日期
            EditText et_Modifydate = FindViewById<EditText>(Resource.Id.Member_Detail_Modifydate);//更新日期
            CheckBox cb_Notsendsms = FindViewById<CheckBox>(Resource.Id.Member_Detail_Notsendsms);//不接受活动短信
            CheckBox cb_Needpost = FindViewById<CheckBox>(Resource.Id.Member_Detail_Needpost);//短信发送账单
            CheckBox cb_Isloss = FindViewById<CheckBox>(Resource.Id.Member_Detail_Isloss);//挂失
            CheckBox cb_Istemp = FindViewById<CheckBox>(Resource.Id.Member_Detail_Istemp);//无卡顾客
            #endregion
            #region 指定不可编辑项
            et_cardno.Enabled = false;
            et_cardno.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_consumecyc.Enabled = false;
            et_consumecyc.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_money.Enabled = false;
            et_money.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_Firstdate.Enabled = false;
            et_Firstdate.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_lastdate.Enabled = false;
            et_lastdate.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_Appenddate.Enabled = false;
            et_Appenddate.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            et_Modifydate.Enabled = false;
            et_Modifydate.SetBackgroundColor(Android.Graphics.Color.ParseColor("#A9A9A9"));
            #endregion

            #region Spinner控件赋值
            //性别
            Java.Lang.Object[] sex = { "请选择", "先生", "女士" };
            var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, sex);
            sp_sex.Adapter = adapter;
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            //所属分店
            string[] subcom = SysVisitor.GetArryList("select subno,comname from subcom");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, subcom);
            sp_subcom.Adapter = adapter;
            //会员级别
            string[] custype = SysVisitor.GetArryList("select cardlevel, carcname from cardtype");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, custype);
            sp_custype.Adapter = adapter;
            //开卡人
            string[] employer = SysVisitor.GetArryList("select emp_no,empname from employer");
            adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, employer);
            sp_empname.Adapter = adapter;
            #endregion
            #region 查看或更新
            if (!string.IsNullOrEmpty(IntentName))
            {
                string sql = @"select cus_name,sex,cardno,subcom,mobile,
                                password,consumecyc,lastmoney,givehavemoney,
                                cus_type,empname,datetime(effecttime) as effecttime,datetime(birthday) as birthday,
                                datetime(first_date) as firstdate,address,datetime(last_date) as lastdate,memo,
                                feature1,feature2,comname,phone,fan,e_mail,datetime(appenddate)as appenddate,datetime(modifydate)as modifydate,
                                notsendsms,needpost,isloss,istemp
                                from customer_small where cardno ='" + IntentName + "'";
                DataTable ldt = new DataTable();
                ldt = SqliteHelper.ExecuteDataTable(sql);
                if (ldt.Rows.Count == 0)
                {
                    return;
                }
                string ls_lastmoney = ldt.Rows[0]["lastmoney"].ToString().Trim();
                string ls_givehavemoney = ldt.Rows[0]["givehavemoney"].ToString().Trim();
                Decimal ldi_money = 0;
                try
                {
                    ldi_money = Convert.ToDecimal(ls_lastmoney);
                }
                catch { }
                try
                {
                    ldi_money += Convert.ToDecimal(ls_givehavemoney);
                }
                catch { }
                #region 赋值
                #region EditText控件
                et_cusname.Text = ldt.Rows[0]["cus_name"].ToString();
                et_cardno.Text = ldt.Rows[0]["cardno"].ToString();
                et_mobile.Text = ldt.Rows[0]["mobile"].ToString();
                et_pwd.Text = ldt.Rows[0]["password"].ToString();
                et_chkpwd.Text = ldt.Rows[0]["password"].ToString();
                et_money.Text = ldi_money.ToString("##0.00");
                et_consumecyc.Text = ldt.Rows[0]["consumecyc"].ToString();
                et_EffectTime.Text = ldt.Rows[0]["effecttime"].ToString();
                et_Birthday.Text = ldt.Rows[0]["birthday"].ToString();
                et_Firstdate.Text = ldt.Rows[0]["firstdate"].ToString();
                et_Address.Text = ldt.Rows[0]["address"].ToString();
                et_lastdate.Text = ldt.Rows[0]["lastdate"].ToString();
                et_memo.Text = ldt.Rows[0]["memo"].ToString();
                et_Feature1.Text = ldt.Rows[0]["feature1"].ToString();
                et_Feature2.Text = ldt.Rows[0]["feature2"].ToString();
                et_Comname.Text = ldt.Rows[0]["comname"].ToString();
                et_Phone.Text = ldt.Rows[0]["phone"].ToString();
                et_Fan.Text = ldt.Rows[0]["fan"].ToString();
                et_Email.Text = ldt.Rows[0]["e_mail"].ToString();
                et_Appenddate.Text = ldt.Rows[0]["appenddate"].ToString();
                et_Modifydate.Text = ldt.Rows[0]["modifydate"].ToString();

                #endregion
                #region CheckBox控件
                if (ldt.Rows[0]["notsendsms"].ToString() == "Y")//不接受活动短信
                {
                    cb_Notsendsms.Checked = true;
                }
                if (ldt.Rows[0]["needpost"].ToString() == "Y")//短信发送账单
                {
                    cb_Needpost.Checked = true;
                }
                if (ldt.Rows[0]["isloss"].ToString() == "Y")//挂失
                {
                    cb_Isloss.Checked = true;
                }
                if (ldt.Rows[0]["istemp"].ToString() == "Y")//无卡顾客
                {
                    cb_Istemp.Checked = true;
                }
                #endregion
                #region Spinner控件
                //性别
                if (ldt.Rows[0]["sex"].ToString() == "Y")
                    sp_sex.SetSelection(1, true);
                else if (ldt.Rows[0]["sex"].ToString() == "N")
                    sp_sex.SetSelection(2, true);
                else
                    sp_sex.SetSelection(0, true);
                //所属分店
                sp_subcom.SetSelection(SysVisitor.GetArryList("select subno,comname from subcom", ldt.Rows[0]["subcom"].ToString()), true);
                //会员级别
                sp_custype.SetSelection(SysVisitor.GetArryList("select cardlevel, carcname from cardtype", ldt.Rows[0]["cus_type"].ToString()), true);
                //开卡人
                sp_empname.SetSelection(SysVisitor.GetArryList("select emp_no,empname from employer", ldt.Rows[0]["empname"].ToString()), true);
                #endregion
                #endregion
            }
            #endregion

            #region 新增
            else
            {
                abupdate = false;
                TextView title = FindViewById<TextView>(Resource.Id.Member_Detail_title);
                title.Text = "录入会员资料";
                btn_save.Text = "添加";
                et_cardno.Enabled = true;
                et_cardno.SetBackgroundColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
            }
            #endregion

            ibtn_cancel.Click += delegate
            {
                StartActivity(typeof(Member));
            };
            btn_save.Click += delegate
            {
                //Spinner控件
                string ls_sex = sp_sex.SelectedItem.ToString();//性别
                if (ls_sex == "请选择")
                    ls_sex = "";
                if (ls_sex == "先生")
                    ls_sex = "Y";
                if (ls_sex == "女士")
                    ls_sex = "N";
                string ls_subcom = sp_subcom.SelectedItem == null ? "" : sp_subcom.SelectedItem.ToString();//所属分店
                if (ls_subcom == "请选择")
                    ls_subcom = "";
                else
                    ls_subcom = SqliteHelper.ExecuteScalar("select subno from subcom where comname='" + ls_subcom + "'");
                string ls_custype = sp_custype.SelectedItem == null ? "" : sp_custype.SelectedItem.ToString();//会员级别
                if (ls_custype == "请选择")
                    ls_custype = "";
                else
                    ls_custype = SqliteHelper.ExecuteScalar("select cardlevel from cardtype where carcname='" + ls_custype + "'");
                string ls_empname = sp_empname.SelectedItem == null ? "" : sp_empname.SelectedItem.ToString();//开卡人
                if (ls_empname == "请选择")
                    ls_empname = "";
                else
                    ls_empname = SqliteHelper.ExecuteScalar("select emp_no from employer where empname='" + ls_empname + "'");

                //CheckBox 控件
                bool lb_Notsendsms = cb_Notsendsms.Checked;
                bool lb_Needpost = cb_Needpost.Checked;
                bool lb_Isloss = cb_Isloss.Checked;
                bool lb_Istemp = cb_Istemp.Checked;

                //EditText控件
                string ls_et_cusname = et_cusname.Text;//姓名
                string ls_et_cardno = et_cardno.Text;//卡号
                string ls_et_mobile = et_mobile.Text;//手机
                string ls_et_pwd = et_pwd.Text;//密码
                string ls_et_chkpwd = et_chkpwd.Text;//确认密码
                string ls_et_money = et_money.Text;//余额
                string ls_et_consumecyc = et_consumecyc.Text;//消费周期
                string ls_et_EffectTime = et_EffectTime.Text;//有效日期
                string ls_et_Birthday = et_Birthday.Text;//生日
                string ls_et_Firstdate = et_Firstdate.Text;//首次来店
                string ls_et_Address = et_Address.Text;//地址
                string ls_et_lastdate = et_lastdate.Text;//最后来店
                string ls_et_memo = et_memo.Text;//备注
                string ls_et_Feature1 = et_Feature1.Text;//会员特征1
                string ls_et_Feature2 = et_Feature2.Text;//会员特征2
                string ls_et_Comname = et_Comname.Text;//公司
                string ls_et_Phone = et_Phone.Text;//固定电话
                string ls_et_Fan = et_Fan.Text;//IC卡号
                string ls_et_Email = et_Email.Text;//Email
                string ls_et_Appenddate = et_Appenddate.Text;//录入日期
                string ls_et_Modifydate = DateTime.Now.ToString();//更新日期

                #region 校验
                if (string.IsNullOrEmpty(ls_et_cusname))
                {
                    Toast.MakeText(this, "姓名不能为空", ToastLength.Short).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_sex))
                {
                    Toast.MakeText(this, "请选择性别", ToastLength.Short).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_et_cardno))
                {
                    Toast.MakeText(this, "卡号不能为空", ToastLength.Short).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_subcom))
                {
                    Toast.MakeText(this, "请选择所属分店", ToastLength.Short).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_et_mobile))
                {
                    Toast.MakeText(this, "手机号不能为空", ToastLength.Short).Show();
                    return;
                }
                if (string.IsNullOrEmpty(ls_custype))
                {
                    Toast.MakeText(this, "请选择会员级别", ToastLength.Short).Show();
                    return;
                }
                if (ls_et_pwd != ls_et_chkpwd)
                {
                    Toast.MakeText(this, "密码不一致,请重新输入", ToastLength.Short).Show();
                    return;
                }
                if (ls_et_pwd != "")//hash密码
                {
                    if (ls_et_pwd.Length != 32)
                    {
                        byte[] result = Encoding.Default.GetBytes(ls_et_pwd);
                        System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
                        byte[] output = md5.ComputeHash(result);
                        ls_et_pwd = BitConverter.ToString(output).Replace("-", "").ToLower();
                    }
                }
                #endregion
                if (ls_et_Firstdate == "")
                    ls_et_Firstdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                ls_et_Modifydate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string ls_sql = "";
                n_create_sql lnv_sql = new n_create_sql();
                lnv_sql.of_SetTable("customer_small");
                lnv_sql.of_AddCol("sex", ls_sex);
                lnv_sql.of_AddCol("subcom", ls_subcom);
                lnv_sql.of_AddCol("cus_type", ls_custype);
                lnv_sql.of_AddCol("empname", ls_empname);
                lnv_sql.of_AddCol("notsendsms", lb_Notsendsms == true ? "Y" : "N");
                lnv_sql.of_AddCol("needpost", lb_Needpost == true ? "Y" : "N");
                lnv_sql.of_AddCol("isloss", lb_Isloss == true ? "Y" : "N");
                lnv_sql.of_AddCol("istemp", lb_Istemp == true ? "Y" : "N");
                lnv_sql.of_AddCol("cus_name", ls_et_cusname);
                lnv_sql.of_AddCol("cardno", ls_et_cardno);
                lnv_sql.of_AddCol("mobile", ls_et_mobile);
                lnv_sql.of_AddCol("password", ls_et_pwd);
                lnv_sql.of_AddCol("consumecyc", ls_et_consumecyc);
                lnv_sql.of_AddCol("effecttime", ls_et_EffectTime);
                lnv_sql.of_AddCol("birthday", ls_et_Birthday);
                lnv_sql.of_AddCol("first_date", ls_et_Firstdate);
                lnv_sql.of_AddCol("address", ls_et_Address);
                lnv_sql.of_AddCol("last_date", ls_et_lastdate);
                lnv_sql.of_AddCol("memo", ls_et_memo);
                lnv_sql.of_AddCol("feature1", ls_et_Feature1);
                lnv_sql.of_AddCol("feature2", ls_et_Feature2);
                lnv_sql.of_AddCol("comname", ls_et_Comname);
                lnv_sql.of_AddCol("phone", ls_et_Phone);
                lnv_sql.of_AddCol("fan", ls_et_Fan);
                lnv_sql.of_AddCol("e_mail", ls_et_Email);
                lnv_sql.of_AddCol("appenddate", ls_et_Appenddate);
                lnv_sql.of_AddCol("modifydate", ls_et_Modifydate);
                bool lb_ok;
                if (abupdate)
                    lb_ok = lnv_sql.of_execute("cardno='" + ls_et_cardno + "'");
                else
                    lb_ok = lnv_sql.of_execute();

                if (lb_ok)
                {
                    if (abupdate)
                        Toast.MakeText(this, "更新成功", ToastLength.Long).Show();
                    if (abupdate)
                        Toast.MakeText(this, "添加成功", ToastLength.Long).Show();
                }
                else
                {
                    if (abupdate)
                        Toast.MakeText(this, "更新失败", ToastLength.Long).Show();
                    if (abupdate)
                        Toast.MakeText(this, "添加失败", ToastLength.Long).Show();
                }
                return;
                #region update
                if (abupdate)
                {
                    ls_sql = "update customer_small set sex='" + ls_sex + "', ";
                    ls_sql += "subcom='" + ls_subcom + "', ";
                    ls_sql += "cus_type='" + ls_custype + "', ";
                    ls_sql += "empname='" + ls_empname + "', ";
                    ls_sql += "notsendsms='" + (lb_Notsendsms == true ? "Y" : "N") + "', ";
                    ls_sql += "needpost='" + (lb_Needpost == true ? "Y" : "N") + "', ";
                    ls_sql += "isloss='" + (lb_Isloss == true ? "Y" : "N") + "', ";
                    ls_sql += "istemp='" + (lb_Istemp == true ? "Y" : "N") + "', ";
                    ls_sql += "cus_name='" + ls_et_cusname + "', ";
                    //ls_sql += "cardno='" + ls_et_cardno + "', ";
                    ls_sql += "mobile='" + ls_et_mobile + "', ";
                    ls_sql += "password='******', ";
                    ls_sql += "consumecyc='" + ls_et_consumecyc + "', ";
                    ls_sql += "effecttime='" + ls_et_EffectTime + "', ";
                    ls_sql += "birthday='" + ls_et_Birthday + "', ";
                    ls_sql += "first_date='" + ls_et_Firstdate + "', ";
                    ls_sql += "address='" + ls_et_Address + "', ";
                    ls_sql += "last_date='" + ls_et_lastdate + "', ";
                    ls_sql += "memo='" + ls_et_memo + "', ";
                    ls_sql += "feature1='" + ls_et_Feature1 + "', ";
                    ls_sql += "feature2='" + ls_et_Feature2 + "', ";
                    ls_sql += "comname='" + ls_et_Comname + "', ";
                    ls_sql += "phone='" + ls_et_Phone + "', ";
                    ls_sql += "fan='" + ls_et_Fan + "', ";
                    ls_sql += "e_mail='" + ls_et_Email + "', ";
                    ls_sql += "appenddate='" + ls_et_Appenddate + "', ";
                    ls_sql += "modifydate='" + ls_et_Modifydate + "' ";
                    ls_sql += "where cardno='" + ls_et_cardno + "' ";
                }
                #endregion
                #region insert
                else
                {

                    ls_sql += @"insert into customer_small (sex,subcom,cus_type,empname,notsendsms,needpost,
                                isloss,istemp,cus_name,cardno,mobile,password,consumecyc,effecttime,birthday,
                                first_date,address,last_date,memo,feature1,feature2,comname,phone,fan,e_mail,
                                appenddate,modifydate) VALUES (
                                " + ls_sex + ","
                                + ls_subcom + ","
                                + ls_custype + ","
                                + ls_empname + ","
                                + (lb_Notsendsms == true ? "Y" : "N") + ","
                                + (lb_Needpost == true ? "Y" : "N") + ","
                                + (lb_Isloss == true ? "Y" : "N") + ","
                                + (lb_Istemp == true ? "Y" : "N") + ","
                                + ls_et_cusname + ","
                                + ls_et_cardno + ","
                                + ls_et_mobile + ","
                                + ls_et_pwd + ","
                                + ls_et_consumecyc + ","
                                + ls_et_EffectTime + ","
                                + ls_et_Birthday + ","
                                + ls_et_Firstdate + ","
                                + ls_et_Address + ","
                                + ls_et_lastdate + ","
                                + ls_et_memo + ","
                                + ls_et_Feature1 + ","
                                + ls_et_Feature2 + ","
                                + ls_et_Comname + ","
                                + ls_et_Phone + ","
                                + ls_et_Fan + ","
                                + ls_et_Email + ","
                                + ls_et_Appenddate + ","
                                + ls_et_Modifydate
                                + ")";
                }
                #endregion

                bool lbOK = SysVisitor.CreateServerDB();
                if (lbOK)
                {
                    int li_row = baseclass.SqlHelper.ExecuteNonQuery(ls_sql);
                    if (li_row > 0 && baseclass.SqlHelper.ErrStr == "")
                    {
                        SqliteHelper.ExecuteScalar(ls_sql);
                        Toast.MakeText(this, "添加成功", ToastLength.Long).Show();
                    }
                    else
                    {
                        if (baseclass.SqlHelper.ErrStr == "")
                            Toast.MakeText(this, "更新失败", ToastLength.Long).Show();
                        else
                            Toast.MakeText(this, "服务器出错:" + baseclass.SqlHelper.ErrStr, ToastLength.Long).Show();
                    }
                }
            };
        }
示例#3
0
文件: Loading.cs 项目: eatage/GyAppMf
        /// <summary>
        /// 加载登陆数据
        /// </summary>
        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))
                {
                    _publicfuns.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)
            {
                RunOnUiThread(() =>
                {
                    Msg.Text = "加载数据出错,请重试";
                });
            }
        }
示例#4
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);
     }
     SqlStr = lnv_sql.SqlStr;
     return li_rc;
 }