Ejemplo n.º 1
0
        /// <summary>
        ///     提交编辑
        /// </summary>
        private bool SubmintEdit()
        {
            if (Link != null)
            {
                Link.FCode    = txtFCode.Text.Trim();
                Link.FName    = tbxFCustomer.Text.Trim();
                Link.FAddress = txtFAddress.Text.Trim();
                Link.FLinkman = txtFLinkman.Text.Trim();
                Link.FPhome   = txtFPhome.Text.Trim();
                Link.FMoile   = txtFMoile.Text.Trim();
                Link.FMemo    = txtFMemo.Text.Trim();
                Link.FSpell   = ChineseSpell.MakeSpellCode(tbxFCustomer.Text.Trim(), "",
                                                           SpellOptions.FirstLetterOnly).ToUpper();
                Link.FCity = txtFCity.Text.Trim();
                Link.FZip  = txtFZip.Text.Trim();

                return(CustomerLinkService.SaveChanges() >= 0);
            }
            return(false);
        }
Ejemplo n.º 2
0
        private void GridEdit()
        {
            #region update
            var dictModified = Grid1.GetModifiedDict();
            foreach (var rowKey in dictModified.Keys)
            {
                int datakey = Convert.ToInt32(Grid1.DataKeys[rowKey][1].ToString());

                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in dictModified[rowKey].Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in dictModified[rowKey].Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var details = CustomerLinkService.Where(p => p.FId == datakey && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();
                var keys    = sKeys.ToString().Split(',');
                var values  = sValues.ToString().Split(',');
                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (details != null)
                        {
                            if (key.Equals("FLinkman"))
                            {
                                details.FLinkman = value;
                            }

                            if (key.Equals("FAddress"))
                            {
                                details.FAddress = value;
                            }

                            if (key.Equals("FPhome"))
                            {
                                details.FPhome = value;
                            }

                            if (key.Equals("FMoile"))
                            {
                                details.FMoile = value;
                            }

                            if (key.Equals("FMemo"))
                            {
                                details.FMemo = value;
                            }

                            if (key.Equals("FType"))
                            {
                                details.FType = value;
                            }
                        }
                    }

                    #endregion
                }


                CustomerLinkService.SaveChanges();
            }
            #endregion


            var addList = Grid1.GetNewAddedList();

            #region AddRow
            foreach (var add in addList)
            {
                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in add.Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in add.Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var keys    = sKeys.ToString().Split(',');
                var values  = sValues.ToString().Split(',');
                var details = new LHCustomerLink();
                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容


                    details.FCompanyId = CurrentUser.AccountComId;
                    details.FCode      = FCode;

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (key.Equals("FLinkman"))
                        {
                            details.FLinkman = value;
                        }

                        if (key.Equals("FAddress"))
                        {
                            details.FAddress = value;
                        }

                        if (key.Equals("FPhome"))
                        {
                            details.FPhome = value;
                        }

                        if (key.Equals("FMoile"))
                        {
                            details.FMoile = value;
                        }

                        if (key.Equals("FMemo"))
                        {
                            details.FMemo = value;
                        }

                        if (key.Equals("FType"))
                        {
                            details.FType = value;
                        }
                    }

                    #endregion
                }
                CustomerLinkService.Add(details);
            }
            #endregion
        }