Esempio n. 1
0
        private List <TKS_FAS_CustomColDesExt> CodeBindValue(List <TKS_FAS_CustomColDes> customColDes,
                                                             TKS_FAS_CaculateHelperDetail data)
        {
            #region foolish bind
            List <TKS_FAS_CustomColDesExt> result = new List <TKS_FAS_CustomColDesExt>();
            foreach (var item in customColDes)
            {
                TKS_FAS_CustomColDesExt newData = new TKS_FAS_CustomColDesExt();
                newData.Id         = item.Id;
                newData.AccountId  = item.AccountId;
                newData.ColumnCode = item.ColumnCode;
                newData.ColumnName = item.ColumnName;
                newData.ParentId   = item.ParentId;

                if (item.ColumnCode == "1")
                {
                    newData.Value = data.Custom1;
                }
                else if (item.ColumnCode == "2")
                {
                    newData.Value = data.Custom2;
                }
                else if (item.ColumnCode == "3")
                {
                    newData.Value = data.Custom3;
                }
                else if (item.ColumnCode == "4")
                {
                    newData.Value = data.Custom4;
                }
                else if (item.ColumnCode == "5")
                {
                    newData.Value = data.Custom5;
                }
                else if (item.ColumnCode == "6")
                {
                    newData.Value = data.Custom6;
                }
                else if (item.ColumnCode == "7")
                {
                    newData.Value = data.Custom7;
                }
                else if (item.ColumnCode == "8")
                {
                    newData.Value = data.Custom8;
                }

                result.Add(newData);
            }

            return(result);

            #endregion
        }
Esempio n. 2
0
        public void CustomDataImport(DataTable dt, string token, string itemId)
        {
            using (cnn = GetConnection())
            {
                var ts = cnn.BeginTransaction();

                try
                {
                    var           user    = this.UserInfoGet(token, ts);
                    AccountSetBLL account = new AccountSetBLL(cnn);
                    var           period  = account.GetActivePeriod(user.AccountId, ts);

                    BalanceBLL balanceBLL = new BalanceBLL(cnn);
                    PeriodBLL  periodBLL  = new PeriodBLL(cnn);

                    string sql = string.Empty;
                    sql = @"delete from TKS_FAS_CaculateHelperDetail where AccountId=@AccountId and ParentId=@ParentId";
                    cnn.Execute(sql, new { AccountId = user.AccountId, ParentId = itemId }, ts);
                    if (dt.DefaultView.ToTable(true, "Name").Rows.Count < dt.Rows.Count)
                    {
                        throw new NormalException("名称不能重复");
                    }
                    for (var i = 0; i < dt.Rows.Count; i++)
                    {
                        var rowItem = dt.Rows[i];
                        TKS_FAS_CaculateHelperDetail fix = new TKS_FAS_CaculateHelperDetail();
                        fix.Id        = Guid.NewGuid().ToString("N");
                        fix.AccountId = user.AccountId;
                        fix.ParentId  = itemId;//当前期间为录入期间
                        fix.IsValid   = 1;
                        fix.Code      = (i + 1).ToString().PadLeft(3, '0');
                        fix.Name      = rowItem["Name"].ToString();
                        fix.Memo      = rowItem["Memo"].ToString();
                        fix.Custom1   = "#nodata#";
                        fix.Custom2   = "#nodata#";
                        fix.Custom3   = "#nodata#";
                        fix.Custom4   = "#nodata#";
                        fix.Custom5   = "#nodata#";
                        fix.Custom6   = "#nodata#";
                        fix.Custom7   = "#nodata#";
                        fix.Custom8   = "#nodata#";
                        cnn.Insert <TKS_FAS_CaculateHelperDetail>(fix, ts);
                    }
                    ts.Commit();
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    throw ex;
                }
            }
        }
Esempio n. 3
0
        private TKS_FAS_CaculateHelperDetail LoadByDic(Dictionary <string, string> saveData)
        {
            TKS_FAS_CaculateHelperDetail data = new TKS_FAS_CaculateHelperDetail();

            data.Id = Guid.NewGuid().ToString();

            data.Code    = saveData["Code"];
            data.Name    = saveData["Name"];
            data.Memo    = saveData["Memo"];
            data.Custom1 = saveData.ContainsKey("Custom1") ? saveData["Custom1"] : "#nodata#";
            data.Custom2 = saveData.ContainsKey("Custom2") ? saveData["Custom2"] : "#nodata#";
            data.Custom3 = saveData.ContainsKey("Custom3") ? saveData["Custom3"] : "#nodata#";
            data.Custom4 = saveData.ContainsKey("Custom4") ? saveData["Custom4"] : "#nodata#";
            data.Custom5 = saveData.ContainsKey("Custom5") ? saveData["Custom5"] : "#nodata#";
            data.Custom6 = saveData.ContainsKey("Custom6") ? saveData["Custom6"] : "#nodata#";
            data.Custom7 = saveData.ContainsKey("Custom7") ? saveData["Custom7"] : "#nodata#";
            data.Custom8 = saveData.ContainsKey("Custom8") ? saveData["Custom8"] : "#nodata#";
            data.IsValid = saveData.ContainsKey("IsValid") ? 1 : 0;
            return(data);
        }
Esempio n. 4
0
        public ResponseCustomDataAdd CustomDataAdd(RequestCustomDataAdd request)
        {
            ResponseCustomDataAdd response = new ResponseCustomDataAdd();

            using (cnn = GetConnection())
            {
                var ts = cnn.BeginTransaction();
                try
                {
                    Dictionary <string, string> saveData = List2Dic(request.Data);

                    var user = this.UserInfoGet(request.Token, ts);
                    var item = cnn.QueryFirst <Max_CaculateHelperDetailCode>(
                        @"select isnull(max(code),0) Code from TKS_FAS_CaculateHelperDetail
        where accountId=@AccountId and parentId=@ParentId", new
                    {
                        AccountId = user.AccountId,
                        ParentId  = request.Head.Id
                    }, ts);
                    saveData["Code"] = (item.Code + 1).ToString().PadLeft(3, '0');
                    #region code ,name verification
                    //var d = cnn.Query(@"select * from TKS_FAS_CaculateHelperDetail
                    //        where code=@Code and accountId=@AccountId and parentId=@ParentId",
                    //    new
                    //    {
                    //        Code = saveData["Code"],
                    //        AccountId = user.AccountId,
                    //        ParentId = request.Head.Id//item id
                    //    }, ts);
                    //if (d.Count() > 0)
                    //{
                    //    throw new NormalException("编码已经存在");
                    //}

                    var d = cnn.Query(@"select * from TKS_FAS_CaculateHelperDetail 
                            where name=@Name and accountId=@AccountId and parentId=@ParentId",
                                      new
                    {
                        Name      = saveData["Name"],
                        AccountId = user.AccountId,
                        ParentId  = request.Head.Id//item id
                    }, ts);
                    if (d.Count() > 0)
                    {
                        throw new NormalException("名称已经存在");
                    }
                    #endregion


                    TKS_FAS_CaculateHelperDetail detail = new TKS_FAS_CaculateHelperDetail();

                    detail           = LoadByDic(saveData);
                    detail.ParentId  = request.Head.Id;
                    detail.AccountId = user.AccountId;
                    cnn.Insert <TKS_FAS_CaculateHelperDetail>(detail, ts);

                    ts.Commit();
                    response.Id = request.Head.Id;

                    response.IsSuccess = true;
                    response.Message   = "新增成功";
                    return(response);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponseCustomDataAdd);
                }
            }
        }