コード例 #1
0
ファイル: CustomerController.cs プロジェクト: onestarzxs/Jxc
        public ActionResult SaveOrUpdate(Customer customer)
        {
            try
            {
                if (customer.Id > 0)
                {
                    customer = this.CustomerRepository.Get(customer.Id);

                    TryUpdateModel(customer);
                }

                if (customer.Pinyin.IsNullOrEmpty() && !customer.Name.IsNullOrEmpty())
                {
                    customer.Pinyin = ChineseToSpell.GetChineseSpell(customer.Name);
                }

                customer = this.CustomerRepository.SaveOrUpdate(customer);

                return(JsonSuccess(customer));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
コード例 #2
0
ファイル: AddressListDb.cs プロジェクト: zxl881203/src
        public bool cUpdateUserData(string yhdm, string zw, string jtzz, string yzbm, string bgdh, string zzdh, string zdbs, string sj, string sjbs, string cz, string xb, string dzyx, string wlch, string bz)
        {
            string sqlString = "";

            if (this.cGetLinkmanDetail(yhdm) != null)
            {
                string str4 = "update pt_txl_nbtxl set v_zw = '" + zw + "',v_jtzz = '" + jtzz + "',v_yzbm = '" + yzbm + "',v_bgdh = '" + bgdh + "',v_zzdh = '" + zzdh + "',c_zdbs = '" + zdbs + "',v_sj = '" + sj + "',";
                sqlString = str4 + "c_sjbs = '" + sjbs + "',v_cz = '" + cz + "',c_xb = '" + xb + "',v_dzyx = '" + dzyx + "',v_wlch = '" + wlch + "',v_bz = '" + bz + "' where v_yhdm = '" + yhdm + "' and c_bs = 'y'";
            }
            else
            {
                int       num   = Convert.ToInt32(publicDbOpClass.QuaryMaxid("pt_txl_nbtxl", "i_id")) + 1;
                DataTable table = new userManageDb().userQuaryDt(yhdm);
                string    word  = table.Rows[0]["v_xm"].ToString();
                int       num2  = Convert.ToInt32(table.Rows[0]["i_bmdm"].ToString());
                string    str3  = new ChineseToSpell().WordToSpell(word);
                object    obj2  = sqlString + "insert into pt_txl_nbtxl (i_id,v_xm,i_bmdm,v_zw,v_jtzz,v_yzbm,v_bgdh,v_zzdh,c_zdbs,v_sj,c_sjbs,v_cz,c_xb,v_dzyx,v_wlch,v_bz,v_yhdm,c_bs,v_hypy) values ";
                string    str5  = string.Concat(new object[] {
                    obj2, " (", num, ",'", word, "',", num2, ",'", zw, "','", jtzz, "','", yzbm, "','", bgdh, "','",
                    zzdh, "','", zdbs, "','", sj, "','", sjbs, "','", cz, "','", xb, "',"
                });
                sqlString = str5 + "'" + dzyx + "','" + wlch + "','" + bz + "','" + yhdm + "','y','" + str3 + "')";
            }
            return(publicDbOpClass.NonQuerySqlString(sqlString));
        }
コード例 #3
0
        public ActionResult SaveOrUpdate(Goods obj, int[] categorys)
        {
            try
            {
                if (obj.Id > 0)
                {
                    obj = this.GoodsRepository.Get(obj.Id);
                    TryUpdateModel(obj);
                }

                if (obj.Pinyin.IsNullOrEmpty() && !obj.Name.IsNullOrEmpty())
                {
                    obj.Pinyin = ChineseToSpell.GetChineseSpell(obj.Name);
                }

                obj = this.GoodsRepository.SaveOrUpdate(obj);

                if (categorys != null)
                {
                    IList <GoodsType> types = this.GoodsTypeRepository.GetGoodsTypes(obj.Id);
                    IList <int>       ids   = categorys.ToList();

                    //
                    //每个商品可以属于多个类别
                    //先删除新类别中不存在的类别
                    int nLen = types.Count - 1;
                    for (int i = nLen; i >= 0; i--)
                    {
                        GoodsType goodsType = types[nLen];

                        if (ids.IndexOf(goodsType.Type.Id) >= 0)
                        {
                            ids.Remove(goodsType.Type.Id);
                        }
                        else
                        {
                            this.GoodsTypeRepository.Delete(goodsType);
                        }
                    }

                    foreach (var id in ids)
                    {
                        this.GoodsTypeRepository.SaveOrUpdate(new GoodsType()
                        {
                            Goods = obj,
                            Type  = this.CommonCodeRepository.Get(id)
                        });
                    }
                }

                return(JsonSuccess(obj));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: zidane0522/usualToolFunction
        private void button1_Click(object sender, EventArgs e)
        {
            int    maxId            = 14016623;//Id号最大值
            string currentName      = "";
            string currentSpellCode = "";

            try
            {
                using (var db = DbEntry.MySqlDb(SqlConst.DB_NAME_ALBBWEB))
                {
                    string QuerySql  = "select name from tm_ictm_copy where id=@id";
                    string UpdateSql = "update tm_ictm_copy set name_1=@SpellCode where id=@id;";
                    //var applicantCount = db.Query<int>().First();
                    for (int i = 1; i <= maxId; i++)
                    {
                        var a = db.Query <string>(QuerySql, new { id = i });
                        if (a != null)
                        {
                            if (a.Count() > 0 && !string.IsNullOrEmpty(a.First()))
                            {
                                currentName      = a.First();
                                currentSpellCode = ChineseToSpell.ConvertToAllSpell(currentName);
                                var updateName_1 = db.Execute(UpdateSql, new { SpellCode = currentSpellCode, id = i });

                                StreamWriter sw = new StreamWriter(@"D:\商标名称转换拼音日志.txt");
                                sw.Write("");
                                string mesg = string.Format("id号:{0}  商标名称:{1}  拼音:{2}", i.ToString(), currentName, currentSpellCode);
                                sw.WriteLine(mesg);
                                this.textBox1.Text = mesg;
                                sw.Close();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                StreamWriter sw = new StreamWriter(@"D:\商标名称转换拼音日志.txt");
                sw.WriteLine(string.Format("商标名称转换异常:{0}", ex.Message));
                sw.Close();
                this.textBox1.Text += ex.Message;
                if (ex.Message == "Incorrect key file for table '.\alibb_tm\tm_ictm_copy.MYI'; try to repair it")
                {
                    string repairSql = "repair table tm_ictm_copy;";
                    using (var db = DbEntry.MySqlDb(SqlConst.DB_NAME_ALBBWEB))
                    {
                        db.Execute(repairSql);
                        this.textBox1.Text += "数据库修复成功,请继续";
                    }
                }
            }
        }
コード例 #5
0
ファイル: AddressListDb.cs プロジェクト: zxl881203/src
        public bool cAddLinkman(string yhdm, string xm, int bmdm, string zw, string jtzz, string yzbm, string bgdh, string zzdh, string zdbs, string sj, string sjbs, string cz, string xb, string dzyx, string wlch, string bz, string xh)
        {
            int num = Convert.ToInt32(publicDbOpClass.QuaryMaxid("pt_txl_nbtxl", "i_id")) + 1;

            string str  = new ChineseToSpell().WordToSpell(xm);
            string str2 = "";
            object obj2 = str2 + "insert into pt_txl_nbtxl (i_id,v_xm,i_bmdm,v_zw,v_jtzz,v_yzbm,v_bgdh,v_zzdh,c_zdbs,v_sj,c_sjbs,v_cz,c_xb,v_dzyx,v_wlch,v_bz,v_yhdm,c_bs,v_hypy,i_xh) values ";
            object obj3 = string.Concat(new object[] {
                obj2, " (", num, ",'", xm, "',", bmdm, ",'", zw, "','", jtzz, "','", yzbm, "','", bgdh, "','",
                zzdh, "','", zdbs, "','", sj, "','", sjbs, "','", cz, "','", xb, "',"
            });

            return(publicDbOpClass.NonQuerySqlString(string.Concat(new object[] { obj3, "'", dzyx, "','", wlch, "','", bz, "','", yhdm, "','n','", str, "',", Convert.ToInt32(xh), ")" })));
        }
コード例 #6
0
ファイル: UserController.cs プロジェクト: onestarzxs/Jxc
        public ActionResult SaveOrUpdate(User user, string psw)
        {
            try
            {
                if (user.Id <= 0)
                {
                    string strUserName = user.LoginName.Trim();

                    MembershipUser membershipuser = Membership.GetUser(strUserName);

                    if (membershipuser != null)
                    {
                        throw new Exception("用户[" + strUserName + "]已经存在,请更换登录名!");
                    }

                    membershipuser = Membership.CreateUser(strUserName, psw);

                    user.MemberShipId = (Guid)membershipuser.ProviderUserKey;
                }
                else
                {
                    user = this.UserRepository.Get(user.Id);

                    TryUpdateModel(user);
                }

                if (user.Pinyin.IsNullOrEmpty() && !user.RealName.IsNullOrEmpty())
                {
                    user.Pinyin = ChineseToSpell.GetChineseSpell(user.RealName);
                }

                user = this.UserRepository.SaveOrUpdate(user);

                return(JsonSuccess(user));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }