Beispiel #1
0
        /// <summary>
        /// Check RFQDetail Data, and bind to systemmessages
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="allFields"></param>
        /// <param name="message"></param>
        public static void CheckData(string key, string value, FieldInfoCollecton allFields, ref SystemMessages message)
        {
            if (allFields[key] != null)
            {
                SGP.BLL.DataModels.FieldInfo fi = allFields[key];

                switch (allFields[key].DataType)
                {
                    case "int":
                        if (!CheckVBalueIfInt(value))
                        {
                            message.isPass = false;
                            message.Messages.Add(key, value + " is not numeric type");
                        }
                        break;
                    case "date":
                        if (!CheckVBalueIfDate(value))
                        {
                            message.isPass = false;
                            message.Messages.Add(key, value + " is not date time type");
                        }
                        break;
                    case "float":
                    case "double":
                        if (!CheckVBalueIffloat(value))
                        {
                            message.isPass = false;
                            message.Messages.Add(key, value + " is not float Type");
                        }
                        break;
                    case "list":
                        if (!CheckVBalueIfList(key, value))
                        {
                            message.isPass = false;
                            message.Messages.Add(key, value + " not exist in data list");
                        }
                        break;
                    case "listsql":
                        if (!CheckVBalueIfListSQL(key, value, fi.KeyValueSource))
                        {
                            message.isPass = false;
                            message.Messages.Add(key, value + " not exist in data list");
                        }
                        break;
                }

            }
        }
Beispiel #2
0
        /// <summary>
        /// 点击REQUOTE时执行
        /// </summary>
        /// <param name="rfqId"></param>
        /// <param name="dicAllTable"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public static bool ReQuote(ref int rfqId, Dictionary<string, Dictionary<string, string>> dicAllTable, FieldInfoCollecton fields)
        {
            string uid = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid;

            string internalNumber = string.Empty;
            if (dicAllTable["SGP_RFQ"] != null && dicAllTable["SGP_RFQ"]["Number"] != null) internalNumber = string.Format("{0}", dicAllTable["SGP_RFQ"]["Number"]);

            RFQDetail rfqOld = GetDetailByInternalNumber(internalNumber);

            //Insert(ref rfqId, dicAllTable, fields);

            //string sql = string.Format("UPDATE SGP_RFQ SET ");

            rfqId = rfqOld.ID;

            rfqId = CreateNewRFQID4ReQuote(rfqId, rfqOld, uid);
            string sql = string.Format("update SGP_RFQGeneral set RFQDateIn=GETDATE(),RFQDateOut=null,QuoteDateIn=null,QuoteDateOut=null,PriceDateOut=null where RFQID={0}",rfqId);

            DbHelperSQL.ExecuteSql(sql);

            return UpdateData(rfqId, dicAllTable, fields);

            //return true;
        }
Beispiel #3
0
        /// <summary>
        /// 更新数据,数据必须先初始化进入所有表
        /// </summary>
        /// <param name="rfqId"></param>
        /// <param name="dicAllTable"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public static bool Update(ref int rfqId, FieldInfoCollecton fields)
        {
            string uid = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid;

            string internalNumber = string.Empty;
            string extNumber = string.Empty;

            SGP.BLL.DataModels.FieldInfo fiNumber = fields.Find(t => string.Compare(t.FieldName, "Number", true) == 0);
            if (fiNumber != null) internalNumber = string.Format("{0}", fiNumber.DataValue);

            SGP.BLL.DataModels.FieldInfo fiExtNumber = fields.Find(t => string.Compare(t.FieldName, "ExtNumber", true) == 0);
            if (fiExtNumber != null) extNumber = string.Format("{0}", fiExtNumber.DataValue);

            if (string.IsNullOrEmpty(internalNumber)) //如果没有内部号码,则根据外部号码,BUILDING等合成内部号码
            {
                internalNumber = PrepareInternalNumber(fields, out extNumber);
            }

            if (fiNumber != null) fiNumber.DataValue = internalNumber;

            RFQDetail detail = null;
            if (string.IsNullOrEmpty(internalNumber) == false)
            {
                //查找当前记录
                detail = GetDetailByInternalNumber(internalNumber);
                if (detail != null)
                {
                    rfqId = detail.RFQID;
                    extNumber = detail.ExtNumber;
                    if (fiExtNumber != null) fiExtNumber.DataValue = extNumber;
                }

                //在有外部号码的情况下,查找数据不存在,则查找最大的一条外部号码对应的数据
                if (detail == null)
                {
                    detail = GetLastDetailByExtNumber(extNumber);
                    if (detail != null)
                    {
                        rfqId = detail.RFQID;
                    }
                }
            }

            //当前记录不存在,但是内部号码存在的情况,先找到外部号码,然后尝试获取该外部号码对应的一条数据
            if (rfqId <= 0 && string.IsNullOrEmpty(internalNumber) == false && detail == null)
            {
                if (internalNumber.IndexOf('-') > 0)
                {
                    string[] ary = internalNumber.Split('-');
                    if (ary.Length >= 2)
                    {
                        extNumber = string.Format("{0}-{1}", ary[0], ary[1]);
                        detail = GetLastDetailByExtNumber(extNumber);
                        if (detail != null)
                        {
                            rfqId = detail.RFQID;
                            if (fiExtNumber != null) fiExtNumber.DataValue = extNumber;
                        }
                    }
                }
            }

            if (rfqId <= 0)//新数据,则创建数据
            {
                rfqId = CreateNewRFQID(uid, out internalNumber);
                extNumber = internalNumber;
                if (fiNumber != null) fiNumber.DataValue = internalNumber;
                if (fiExtNumber != null) fiExtNumber.DataValue = internalNumber;
            }

            if (detail != null)// 如果在有老数据存在的情况下,判断Building是否有修改,如果有需要一条复制数据
            {
                extNumber = detail.ExtNumber;
                string revOld = detail.InternalRevisionNumber;
                string buildingOld = detail.Building;
                string buildingNew = string.Empty;
                string revNew = string.Empty;
                if (fields["Building"] != null) buildingNew = string.Format("{0}", fields["Building"].DataValue);
                if (fields["InternalRevisionNumber"] != null) revNew = string.Format("{0}", fields["InternalRevisionNumber"].DataValue);

                //创建新数据
                string newNumber = string.Empty;
                rfqId = CreateNewRFQID4BuildingChange(rfqId, detail, buildingNew, revNew, uid, out newNumber);
                if (fiNumber != null) fiNumber.DataValue = newNumber;
            }

            if (rfqId > 0)
            {
                return UpdateData(rfqId, fields);
            }

            return false;
        }
        public static string GenrateTableBody(FieldInfoCollecton Fields)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<tr>");

            foreach (FieldInfo f in Fields)
            {
                sb.AppendFormat("<td>{0}</td>", UIComponent.CreateDetailComponent(f));
            }
            sb.Append("</tr>");
            return sb.ToString();
        }
Beispiel #5
0
        private static string PrepareInternalNumber(FieldInfoCollecton fields, out string extNumber)
        {
            string internalNumber = string.Empty;
            extNumber = string.Empty;
            SGP.BLL.DataModels.FieldInfo fiNumber = fields.Find(t => string.Compare(t.FieldName, "Number", true) == 0);
            if (fiNumber != null) internalNumber = string.Format("{0}", fiNumber.DataValue);

            SGP.BLL.DataModels.FieldInfo fiExtNumber = fields.Find(t => string.Compare(t.FieldName, "ExtNumber", true) == 0);
            if (fiExtNumber != null) extNumber = string.Format("{0}", fiExtNumber.DataValue);

            //如果内部编号为空,但是外部编号不为空,则合成外部编号
            if (string.IsNullOrEmpty(internalNumber))
            {
                if (string.IsNullOrEmpty(extNumber) == false)
                {
                    string rev = string.Empty;
                    string building = string.Empty;
                    SGP.BLL.DataModels.FieldInfo fiRev = fields.Find(t => string.Compare(t.FieldName, "InternalRevisionNumber", true) == 0);
                    SGP.BLL.DataModels.FieldInfo fiBuilding = fields.Find(t => string.Compare(t.FieldName, "Building", true) == 0);
                    if (fiRev != null) rev = string.Format("{0}", fiRev.DataValue);
                    if (fiBuilding != null) building = string.Format("{0}", fiBuilding.DataValue);

                    if (string.IsNullOrEmpty(rev)) rev = "01";
                    rev = rev.PadLeft(2, '0');

                    if (string.IsNullOrEmpty(building))
                    {
                        internalNumber = extNumber;
                    }
                    else
                    {
                        internalNumber = string.Format("{0}-{1}{2}", extNumber, rev, building);
                    }
                }
            }

            return internalNumber;
        }
Beispiel #6
0
        public static bool __Insert(ref int rfqId, Dictionary<string, Dictionary<string, string>> dicAllTable, FieldInfoCollecton fields)
        {
            string uid = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid;

            string strSql = string.Empty;
            //string strSql = "INSERT INTO SGP_RFQ(Number, EmployeeID) VALUES(dbo.fx_newGPRFQ('" + uid + "'), '" + uid + "');SELECT @@IDENTITY";

            using (TScope ts = new TScope())
            {
                try
                {
                    rfqId = CreateNewRFQID(uid);
                    //string tempId = Convert.ToString(DbHelperSQL.GetSingle(strSql));
                    string tempId = rfqId.ToString();

                    //int.TryParse(tempId, out rfqId);
                    if (rfqId > 0)
                    {
                        if (dicAllTable.Keys.Contains("SGP_RFQ"))
                        {
                            dicAllTable.Remove("SGP_RFQ");
                        }

                        foreach (string tableName in dicAllTable.Keys)
                        {
                            List<SqlParameter> listParames = new List<SqlParameter>();
                            string strField = "RFQID,";
                            string strValue = "@RFQID,";
                            listParames.Add(new SqlParameter("@RFQID", rfqId));
                            foreach (KeyValuePair<string, string> kvField in dicAllTable[tableName])
                            {
                                strField += kvField.Key + ",";
                                strValue += "@" + kvField.Key + ",";
                                if (fields[kvField.Key].DataType == BLL.DataModels.FieldInfo.DATATYPE_DATETIME && String.IsNullOrEmpty(kvField.Value))
                                {
                                    listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                                }
                                else
                                {
                                    if (String.IsNullOrEmpty(kvField.Value.Trim()))
                                    {

                                        listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                                    }
                                    else
                                    {
                                        listParames.Add(new SqlParameter("@" + kvField.Key, kvField.Value));
                                    }
                                }

                            }
                            strField = strField.TrimEnd(',');
                            strValue = strValue.TrimEnd(',');

                            strSql = "INSERT INTO " + tableName + "(" + strField + ") VALUES(" + strValue + ")";

                            DbHelperSQL.ExecuteSql(strSql, listParames.ToArray());
                        }

                        UpdateSpecialFields(rfqId);

                        strSql = "Insert Into SGP_RFQHistory select *,getdate() from v_sgp where RFQID=@RFQID";
                        DbHelperSQL.ExecuteSql(strSql, new SqlParameter("@RFQID", tempId));

                        List<SqlParameter> Params = new List<SqlParameter>() { new SqlParameter("@RFQID", tempId), new SqlParameter("@UID", uid) };
                        strSql = "Insert into [SYS_WFProcessLog] select @RFQID,1,0,1,getdate(),@UID,NULL";
                        DbHelperSQL.ExecuteSql(strSql, Params.ToArray());

                        return true;
                    }
                    else
                    {
                        ts.Rollback();
                    }
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    throw ex;
                }
            }

            return false;
        }
        private static string GenrateCategory(ref int ID, List<FieldCategory> allGategory, FieldCategory fc, object data, string ActivityID)
        {
            StringBuilder sb = new StringBuilder();
            ID++;

            sb.Append(@"<div class=""panel panel-default"">
                           <div class=""panel-heading"">
                              <a href=""#faq-1-" + ID.ToString() + @""" data-parent=""#faq-list-" + ID.ToString() + @""" data-toggle=""collapse"" class=""accordion-toggle"">
                              <i class=""pull-right icon-chevron-down"" data-icon-hide=""icon-chevron-down"" data-icon-show=""icon-chevron-left""></i>
                              <i class=""icon-user bigger-130""></i>&nbsp; " + fc.CategoryName + @":</a>
                           </div>");
            sb.Append(@"<div class=""panel-collapse in"" id=""faq-1-" + ID.ToString() + @""" style=""height: auto;""><div class=""panel-body"">");

            sb.Append(@"<form id='fm' method='post'><table>");
            FieldInfoCollecton enablefields = new FieldInfoCollecton();

            foreach (BI.SGP.BLL.DataModels.FieldInfo fi in fc.Fields)
            {
                if (fi.Enable == 1)
                {

                    enablefields.Add(fi);
                }
            }

            double RowCount = enablefields.Count;
            int colSize = 4;
            sb.Append(@"<input type=""hidden"" id=""ID"" name=""ID"" value=""" + ActivityID + @"""  /><tbody  style=""width:100%"">");

            int colSpanTotal = 0;
            for (int i = 0; i < RowCount; i++)
            {
                if (colSpanTotal == 0)
                {
                    sb.Append("<tr>");
                }

                colSpanTotal++;

                int curSpan;
                if (enablefields[i].ColSpan == 0)
                {
                    curSpan = 1;
                }
                else if (enablefields[i].ColSpan > (colSize - 1))
                {
                    curSpan = colSize - 1;
                }
                else
                {
                    curSpan = enablefields[i].ColSpan;
                }
                colSpanTotal += curSpan;

                if (colSpanTotal <= colSize)
                {
                    sb.Append(UIManager.GenerateField(enablefields[i]));
                }

                if (colSpanTotal == colSize)
                {
                    sb.Append("</tr>");
                    colSpanTotal = 0;
                }

                if (colSpanTotal > colSize)
                {
                    sb.Append("</tr>");
                    colSpanTotal = 0;
                    i--;
                }
            }
            sb.Append("</tbody>");
            sb.Append("</form></table>");
            sb.Append(@"</div></div></div>");

            return sb.ToString();
        }
Beispiel #8
0
 public static FieldInfoCollecton GetSubFields(string subFieldType, FieldInfoCollecton AllFields)
 {
     FieldInfoCollecton fields = new FieldInfoCollecton();
     foreach (FieldInfo f in fields)
     {
         if (String.Compare(f.SubDataType, subFieldType, true) == 0)
         {
             fields.Add(f);
         }
     }
     return fields;
 }
Beispiel #9
0
        public void SetFieldValue(KeyValuePair<string, object> kv, FieldInfoCollecton fields, bool subDataToArray)
        {
            FieldInfo f = fields[kv.Key];
            if (f != null)
            {
                if (subDataToArray && !(kv.Value is ArrayList))
                {
                    f.DataValue = new ArrayList() { kv.Value };
                }
                else
                {
                    f.DataValue = kv.Value;
                }

                if (!String.IsNullOrEmpty(f.TableName))
                {
                    f.CurrentlyInUse = true;
                }
            }
        }
Beispiel #10
0
        public static FieldInfoCollecton GetAllFields(params string[] categoryType)
        {
            string strWhere = "";
            foreach (string ct in categoryType)
            {
                if (strWhere != "")
                {
                    strWhere += " OR ";
                }

                strWhere += String.Format("CategoryType='{0}'", ct);
            }
            if (strWhere != "") strWhere = " AND (" + strWhere + ")";

            string strSql = String.Format("SELECT t1.* FROM SYS_FieldInfo t1, SYS_FieldCategory t2 WHERE t1.CategoryID = t2.ID AND t1.Status = 1 {0} ORDER BY t1.Sort", strWhere);
            DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
            FieldInfoCollecton fields = new FieldInfoCollecton(ModelHandler<FieldInfo>.FillModel(dt));
            return fields;
        }
Beispiel #11
0
 public static FieldInfoCollecton GetAllFieldsOrderbyCategoryID()
 {
     string strSql = "SELECT * FROM SYS_FieldInfo WHERE Status = 1 order by CategoryID,sort";
     DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
     FieldInfoCollecton fields = new FieldInfoCollecton(ModelHandler<FieldInfo>.FillModel(dt));
     return fields;
 }
Beispiel #12
0
        private void UpdateSubData(FieldInfoCollecton fields, string tableName, string dataType)
        {
            string strSql = "DELETE FROM " + tableName + " WHERE SCIID=@SCIID AND DataType=@DataType";
            List<SqlParameter> listMainParames = new List<SqlParameter>();
            listMainParames.Add(new SqlParameter("@SCIID", this.ID));
            listMainParames.Add(new SqlParameter("@DataType", dataType));
            DbHelperSQL.ExecuteSql(strSql, listMainParames.ToArray());

            string strField = "ID,SCIID,DataType,", strValue = "@ID,@SCIID,@DataType,";
            int subCount = 0;

            foreach (FieldInfo f in fields)
            {
                ArrayList arrVal = f.DataValue as ArrayList;
                if (arrVal != null)
                {
                    if (f.CurrentlyInUse == true)
                    {
                        strField += f.FieldName + ",";
                        strValue += "@" + f.FieldName + ",";
                    }
                    if (subCount == 0)
                    {
                        subCount = arrVal.Count;
                    }
                }
            }
            strField = strField.TrimEnd(',');
            strValue = strValue.TrimEnd(',');
            strSql = "INSERT INTO " + tableName + "(" + strField + ") VALUES(" + strValue + ")";

            for (int i = 0; i < subCount; i++)
            {
                List<SqlParameter> listParames = new List<SqlParameter>();
                listParames.AddRange(listMainParames);
                listParames.Add(new SqlParameter("@ID", i + 1));

                foreach (FieldInfo f in fields)
                {
                    ArrayList arrVal = f.DataValue as ArrayList;
                    listParames.Add(new SqlParameter("@" + f.FieldName, String.IsNullOrEmpty(arrVal[i].ToString()) ? DBNull.Value : arrVal[i]));
                }
                DbHelperSQL.ExecuteSql(strSql, listParames.ToArray());
            }
        }
Beispiel #13
0
        //public static string GenrateCategorySubFields(FieldCategory category)
        //{
        //    int colSpan = category.ColSpan;
        //    StringBuilder sb = new StringBuilder();
        //    if (category.SubFields.Count > 0)
        //    {
        //        int subCount = 0;
        //        bool canEdit = false;
        //        sb.AppendFormat("<tr><td colspan='{0}'><div style='overflow:auto;' class='detail-subdata-list'><table id='tb-{1}' style='width:100%;margin-bottom:0px;' class='table table-striped table-bordered table-hover'>", colSpan, category.SubFields[0].SubDataType);
        //        sb.Append("<thead><tr style='background-image:-webkit-gradient(linear,left 0,left 100%,from(#f8f8f8),to(#ececec))'>");
        //        StringBuilder sbSubLine = new StringBuilder();
        //        foreach (FieldInfo f in category.SubFields)
        //        {
        //            if (subCount == 0 && f.DataValue is ArrayList)
        //            {
        //                subCount = ((ArrayList)f.DataValue).Count;
        //            }
        //            string fontColor = f.WFRequiredOption == RequiredOption.Required ? ";color:red" : "";
        //            if (!canEdit && f.Visible != 0)
        //            {
        //                canEdit = true;
        //            }
        //            sbSubLine.AppendFormat("<th nowrap style='padding:8px;width:{0}px{1}'>{2}</th>", f.Width == 0 ? 100 : f.Width, fontColor, f.DisplayName);
        //        }
        //        sb.AppendFormat("<th style='padding:8px;width:30px'>{0}</th>", canEdit ? "<a href='javascript:void(0)' ng-click='addrow()' onclick='addDetail(\"" + category.SubFields[0].SubDataType + "\")'><i class='green icon-plus bigger-130'></i></a>" : "");
        //        sb.Append(sbSubLine);
        //        sb.Append("</tr></thead>");
        //        sb.Append("<tbody>");
        //        if (subCount == 0)
        //        {
        //            sb.Append(GenrateSubLine(category.SubFields, -1, false));
        //        }
        //        else
        //        {
        //            for (int i = 0; i < subCount; i++)
        //            {
        //                sb.Append(GenrateSubLine(category.SubFields, i, canEdit && i > 0));
        //            }
        //        }
        //        sb.Append("</tbody>");
        //        sb.Append("</div></table>");
        //        sb.AppendFormat("<script language='javascript'>var subdata_{0} = {1}</script>", category.SubFields[0].SubDataType, Newtonsoft.Json.JsonConvert.SerializeObject(GenrateSubLine(category.SubFields, -1, true)));
        //        sb.Append("</td></tr>");
        //    }
        //    return sb.ToString();
        //}
        public static string GenrateSubLine(FieldInfoCollecton subFields, int dataIndex, bool delButton)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat(@"<tr ng-repeat='item in items'>");
            sb.AppendFormat(@"<td nowrap style='padding:8px;'>{0}</td>", delButton ? "<a href='javascript:void(0)' ng-click='removerow($index)'><i class='red icon-remove bigger-130'></i></a>" : "");
            foreach (FieldInfo f in subFields)
            {

                sb.AppendFormat("<td>{0}</td>", UIComponent.CreateDetailComponent(f));
            }
            sb.AppendFormat(@"</tr>");
            return sb.ToString();
        }
 private static void MarkRequiredFields(FieldInfoCollecton fields)
 {
     foreach (FieldInfo f in fields)
     {
         f.WFRequiredOption = f.Options.Required == true ? RequiredOption.Required : RequiredOption.Optional;
     }
 }
Beispiel #15
0
 /// <summary>
 /// 真正写入数据,不做任何判断
 /// </summary>
 /// <param name="rfqId"></param>
 /// <param name="dicAllTable"></param>
 /// <param name="fields"></param>
 /// <returns></returns>
 public static bool UpdateData(int rfqId, FieldInfoCollecton fields)
 {
     Dictionary<string, Dictionary<string, string>> dicAllTable = PrepareData(fields);
     return UpdateData(rfqId, dicAllTable, fields);
 }
Beispiel #16
0
 private FieldInfoCollecton GetSubFields()
 {
     if (!String.IsNullOrWhiteSpace(ID))
     {
         string strSql = "SELECT * FROM SYS_FieldInfo t1, SYS_FieldCategory t2 WHERE t1.CategoryID = t2.ID AND t2.ID = @ID AND t1.Status = 1 AND t1.Enable = 1 AND t1.SubDataType <> '' ORDER BY t1.Sort";
         DataTable dt = DbHelperSQL.Query(strSql, new SqlParameter("@ID", ID)).Tables[0];
         FieldInfoCollecton fields = new FieldInfoCollecton(ModelHandler<FieldInfo>.FillModel(dt));
         RelatedCategory(fields);
         return fields;
     }
     return null;
 }
Beispiel #17
0
        /// <summary>
        /// 真正写入数据,不做任何判断
        /// </summary>
        /// <param name="rfqId"></param>
        /// <param name="dicAllTable"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public static bool UpdateData(int rfqId, Dictionary<string, Dictionary<string, string>> dicAllTable, FieldInfoCollecton fields)
        {
            string uid = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid;

            if (dicAllTable.Keys.Contains("SGP_RFQ"))
            {
                dicAllTable.Remove("SGP_RFQ");
            }

            using (TScope ts = new TScope())
            {
                try
                {
                    BI.SGP.BLL.Event.UserChangedEvent uce = new Event.UserChangedEvent(rfqId);
                    uce.DoBefore();

                    string strSql = "";
                    foreach (string tableName in dicAllTable.Keys)
                    {
                        List<SqlParameter> listParames = new List<SqlParameter>();
                        string strField = "";

                        foreach (KeyValuePair<string, string> kvField in dicAllTable[tableName])
                        {
                            if (kvField.Key == "RFQDateIn") continue;
                            if (kvField.Key == "RFQDateOut") continue;
                            if (kvField.Key == "QuoteDateIn") continue;
                            if (kvField.Key == "QuoteDateOut") continue;
                            if (kvField.Key == "PriceDateOut") continue;

                            strField += kvField.Key + "=@" + kvField.Key + ",";
                            if (fields[kvField.Key].DataType == BLL.DataModels.FieldInfo.DATATYPE_DATETIME && String.IsNullOrEmpty(kvField.Value))
                            {
                                listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(kvField.Value.Trim()))
                                {

                                    listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                                }
                                else
                                {
                                    listParames.Add(new SqlParameter("@" + kvField.Key, kvField.Value));
                                }
                            }

                        }
                        strField = strField.TrimEnd(',');
                        listParames.Add(new SqlParameter("@RFQID", rfqId));
                        strSql = String.Format("UPDATE SGP_RFQ SET EmployeeID = '{0}', LastUpdate=getdate() WHERE ID = {1};", uid, rfqId);
                        strSql += "UPDATE " + tableName + " SET " + strField + " WHERE RFQID = @RFQID";

                        DbHelperSQL.ExecuteSql(strSql, listParames.ToArray());

                    }

                    UpdateSpecialFields(rfqId);

                    strSql = "Insert Into SGP_RFQHistory select *,getdate() from v_sgp where RFQID=@RFQID";
                    DbHelperSQL.ExecuteSql(strSql, new SqlParameter("@RFQID", rfqId));

                    uce.DoAfter();
                    return true;
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    throw ex;
                }
            }
            return true;
        }
Beispiel #18
0
 private void RelatedCategory(FieldInfoCollecton fields)
 {
     if (fields != null)
     {
         foreach (FieldInfo f in fields)
         {
             f.Category = this;
             f.Options = new DataOptions(f.DataOptions, this.PageType);
         }
     }
 }
        private static string GenratePrintPage(ref int ID, List<FieldCategory> allGategory, FieldCategory fc, object data, string ActivityID)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(@"<div><h3 align=""center"">" + fc.CategoryName + "</h3></div>");

            sb.Append(@"<table style=""width:98%"" id=""listTable"" border=""1"" align=""center"" cellpadding=""0"" cellspacing=""0"" bordercolor=""#000000"" >");
            FieldInfoCollecton enablefields = new FieldInfoCollecton();

            foreach (BI.SGP.BLL.DataModels.FieldInfo fi in fc.Fields)
            {
                if (fi.Enable == 1)
                {
                    enablefields.Add(fi);
                }
            }

            double RowCount = enablefields.Count;
            int colSize = 4;
            int colSpanTotal = 0;
            for (int i = 0; i < RowCount; i++)
            {
                if (colSpanTotal == 0)
                {
                    sb.Append(@"<tr style=""height:25px"">");
                }

                colSpanTotal++;

                int curSpan;
                if (enablefields[i].ColSpan == 0)
                {
                    curSpan = 1;
                }
                else if (enablefields[i].ColSpan > (colSize - 1))
                {
                    curSpan = colSize - 1;
                }
                else
                {
                    curSpan = enablefields[i].ColSpan;
                }
                colSpanTotal += curSpan;

                if (colSpanTotal <= colSize)
                {
                    sb.Append(UIManager.GeneratePrintField(enablefields[i]));
                }

                if (colSpanTotal == colSize)
                {
                    sb.Append("</tr>");
                    colSpanTotal = 0;
                }

                if (colSpanTotal > colSize)
                {
                    sb.Append("</tr>");
                    colSpanTotal = 0;
                    i--;
                }

            }
            sb.Append("</table>");

            return sb.ToString();
        }
Beispiel #20
0
        /// <summary>
        /// 将字段放入到字典中准备生成SQL语句
        /// </summary>
        /// <param name="fields"></param>
        /// <returns></returns>
        private static Dictionary<string, Dictionary<string, string>> PrepareData(FieldInfoCollecton fields)
        {
            Dictionary<string, Dictionary<string, string>> dicAllTable = new Dictionary<string, Dictionary<string, string>>();

            foreach (BI.SGP.BLL.DataModels.FieldInfo fc in fields)
            {
                if (fc.CurrentlyInUse == false) continue;
                string tableName = fc.TableName.ToUpper();
                if (!dicAllTable.ContainsKey(tableName)) dicAllTable.Add(tableName, new Dictionary<string, string>());

                dicAllTable[tableName].Add(fc.FieldName, string.Format("{0}", fc.DataValue));
            }
            return dicAllTable;
        }
Beispiel #21
0
        private static string GenrateCategory(ref int ID, List<FieldCategory> allGategory, FieldCategory fc, object data, string ActivityID, bool needHeader)
        {
            StringBuilder sb = new StringBuilder();

            FieldCategory priceDetailCategroy = allGategory.Find(t => t.ID == "7");
            FieldCategory termsConditionsCategory = allGategory.Find(t => t.ID == "8");
            FieldCategory VVItermsConditionsCategory = allGategory.Find(t => t.ID == "9");
            FieldCategory VVIpriceDetailCategroy = allGategory.Find(t => t.ID == "15");

            String GRole = fc.AllowedRoles;

            string[] GategoryRoles = GRole.Split(',');

            if (!GategoryRoles.Contains("ALL"))
            {
                AccessServiceReference.Role[] role = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Roles;
                List<string> CurrRole = new List<string>();
                if (role != null)
                {
                    foreach (AccessServiceReference.Role r in role)
                    {
                        CurrRole.Add(r.Name);
                    }
                }

                List<string> ExcepCurrRole = GategoryRoles.Except(CurrRole).ToList();
                if (ExcepCurrRole.Count > 0)
                {
                    return string.Empty;
                }
            }
            ID++;
            string fcactivity = fc.ActivityID;
            if (needHeader)
            {
                if (fcactivity != null)
                {
                    string[] curractivitys = fcactivity.Split(',');
                    if (curractivitys.Contains(ActivityID))
                    {
                        sb.Append(@"<div class=""panel panel-default"">
                           <div class=""panel-heading"">
                              <a href=""#faq-1-" + ID.ToString() + @""" data-parent=""#faq-list-" + ID.ToString() + @""" data-toggle=""collapse"" class=""accordion-toggle collapsed"">
                              <i class=""pull-right icon-chevron-down"" data-icon-hide=""icon-chevron-down"" data-icon-show=""icon-chevron-left""></i>
                              <i class=""icon-user bigger-130""></i>&nbsp; " + fc.CategoryName + @":</a>
                           </div>");
                        sb.Append(@"<div class=""panel-collapse collapse"" id=""faq-1-" + ID.ToString() + @""" style=""height: auto;""><div class=""panel-body"">");
                    }
                    else
                    {
                        sb.Append(@"<div class=""panel panel-default"">
                           <div class=""panel-heading"">
                              <a href=""#faq-1-" + ID.ToString() + @""" data-parent=""#faq-list-" + ID.ToString() + @""" data-toggle=""collapse"" class=""accordion-toggle"">
                              <i class=""pull-right icon-chevron-down"" data-icon-hide=""icon-chevron-down"" data-icon-show=""icon-chevron-left""></i>
                              <i class=""icon-user bigger-130""></i>&nbsp; " + fc.CategoryName + @":</a>
                           </div>");
                        sb.Append(@"<div class=""panel-collapse in"" id=""faq-1-" + ID.ToString() + @""" style=""height: auto;""><div class=""panel-body"">");
                    }
                }
                else
                {
                    sb.Append(@"<div class=""panel panel-default"">
                           <div class=""panel-heading"">
                              <a href=""#faq-1-" + ID.ToString() + @""" data-parent=""#faq-list-" + ID.ToString() + @""" data-toggle=""collapse"" class=""accordion-toggle"">
                              <i class=""pull-right icon-chevron-down"" data-icon-hide=""icon-chevron-down"" data-icon-show=""icon-chevron-left""></i>
                              <i class=""icon-user bigger-130""></i>&nbsp; " + fc.CategoryName + @":</a>
                           </div>");
                    sb.Append(@"<div class=""panel-collapse in"" id=""faq-1-" + ID.ToString() + @""" style=""height: auto;""><div class=""panel-body"">");
                }
            }

            sb.Append(@"<table>");
            {

                FieldInfoCollecton enablefields = new FieldInfoCollecton();

                foreach (BI.SGP.BLL.DataModels.FieldInfo fi in fc.Fields)
                {
                    if (fi.Enable == 1)
                    {

                        enablefields.Add(fi);
                    }

                }

                double RowCount = enablefields.Count;
                int colSize = 8;
                if (fc.CategoryName == "Closure Status")
                {
                    colSize = 6;
                    sb.Append("<thead style='width:100%'><tr><th style='width:15%'></th><th style='width:18.3333%'></th><th style='width:15%'></th><th style='width:18.3333%'></th><th style='width:15%'></th><th style='width:18.3333%'></th></tr></thead>");
                }
                else if (fc.ID == "5") //价格区域
                {
                    colSize = 6;
                    sb.Append("<thead style='width:100%'><tr><th style='width:20%'></th><th style='width:13%'></th><th style='width:20%'></th><th style='width:13%'></th><th style='width:20%'></th><th style='width:14%'></th></tr></thead>");
                }
                else if (fc.ID == "9")
                {
                    colSize = 10;
                    sb.Append("<thead style='width:100%'><tr><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th><th style='width:10% !important'></th></tr></thead>");
                }
                else
                {

                    sb.Append("<thead style='width:100%'><tr><th style='width:10%'></th><th style='width:15%'></th><th style='width:10%'></th><th style='width:15%'></th><th style='width:10%'></th><th style='width:15%'></th><th style='width:10%'></th><th style='width:15%'></th></tr></thead>");
                }

                sb.Append("<tbody  style='width:100%'>");

                int colSpanTotal = 0;

                for (int i = 0; i < RowCount; i++)
                {
                    if (colSpanTotal == 0)
                    {
                        sb.Append("<tr>");
                    }

                    colSpanTotal++;

                    int curSpan;
                    if (enablefields[i].ColSpan == 0)
                    {
                        curSpan = 1;
                    }
                    else if (enablefields[i].ColSpan > (colSize - 1))
                    {
                        curSpan = colSize - 1;
                    }
                    else
                    {
                        curSpan = enablefields[i].ColSpan;
                    }
                    colSpanTotal += curSpan;

                    if (colSpanTotal <= colSize)
                    {
                        sb.Append(GenerateField(enablefields[i]));
                    }

                    if (colSpanTotal == colSize)
                    {
                        sb.Append("</tr>");
                        colSpanTotal = 0;
                    }

                    if (colSpanTotal > colSize)
                    {
                        sb.Append("</tr>");
                        colSpanTotal = 0;
                        i--;
                    }
                }

                sb.Append("</tbody>");
                sb.Append("</table>");

                //价格区域
                if (fc.ID == "5")
                {
                    //绘制价格表格
                    //sb.AppendLine("<div style='padding:5px;'>");
                    sb.Append(GenerateCategoryForPriceDetail(priceDetailCategroy));
                    //sb.AppendLine("</div>");

                    //绘制Terms & Conditions头部
                    sb.AppendFormat(@"
            <div class='panel-heading' style='background:#f7f7f7;font-weight:bold;text-align:center'>
            {0}
            </div>"
                , termsConditionsCategory.CategoryName);

                    //绘制Terms & Conditions主体
                    string s = GenrateCategory(ref ID, allGategory, termsConditionsCategory, data, ActivityID, false);
                    sb.AppendLine(s);
                }

                if (fc.ID == "15")
                {
                    //绘制价格表格
                    //sb.AppendLine("<div style='padding:5px;'>");
                    sb.Append(GenerateCategoryForVerticalDetail(VVIpriceDetailCategroy));
                    //sb.AppendLine("</div>");

                }

                if (fc.ID == "4")
                {
                    //绘制Terms & Conditions头部
                    sb.AppendFormat(@"
            <div class='panel-heading' style='background:#f7f7f7;font-weight:bold;text-align:center'>
            {0}
            </div>", VVItermsConditionsCategory.CategoryName);
                    //绘制Terms & Conditions主体
                    string s = GenrateCategory(ref ID, allGategory, VVItermsConditionsCategory, data, ActivityID, false);
                    sb.AppendLine(s);
                }
            }
            if (needHeader)
            {
                sb.Append(@"</div></div></div>");
            }

            return sb.ToString();
        }
        public static string GenrateCategoryFields(FieldInfoCollecton fields, int colSpan, Dictionary<string, string> dcwi)
        {
            StringBuilder sb = new StringBuilder();
            FieldInfoCollecton enablefields = fields;
            int RowCount = enablefields.Count;

            Dictionary<int, Dictionary<string, string>> dcWidth = new Dictionary<int, Dictionary<string, string>>();

            if (dcwi != null)
            {
                dcWidth.Add(colSpan, dcwi);
            }

            if (!dcWidth.ContainsKey(4))
            {
                Dictionary<string, string> dcw = new Dictionary<string, string>();
                dcw.Add("lableWidth", "20%");
                dcw.Add("comWidth", "30%");
                dcWidth.Add(4, dcw);
            }

            if (!dcWidth.ContainsKey(6))
            {
                Dictionary<string, string> dcw = new Dictionary<string, string>();
                dcw.Add("lableWidth", "15%");
                dcw.Add("comWidth", "18%");
                dcWidth.Add(6, dcw);
            }

            int colSpanTotal = 0;
            for (int i = 0; i < RowCount; i++)
            {
                if (colSpanTotal == 0)
                {
                    sb.Append("<tr>");
                }

                colSpanTotal++;

                int curSpan;
                if (enablefields[i].ColSpan == 0)
                {
                    curSpan = 1;
                }
                else if (enablefields[i].ColSpan > (colSpan - 1))
                {
                    curSpan = colSpan - 1;
                }
                else
                {
                    curSpan = enablefields[i].ColSpan;
                }
                colSpanTotal += curSpan;

                if (enablefields[i].ExtEmptyColSpan > 0)
                {
                    colSpanTotal += enablefields[i].ExtEmptyColSpan;
                }

                if (colSpanTotal <= colSpan)
                {
                    sb.Append(UIComponent.CreateDetailComponentAndLable(enablefields[i], colSpan, dcWidth));
                }

                if (colSpanTotal == colSpan)
                {
                    sb.Append("</tr>");
                    colSpanTotal = 0;
                }

                if (colSpanTotal > colSpan)
                {
                    sb.Append("</tr>");
                    colSpanTotal = 0;
                    i--;
                }
            }

            if ((RowCount*2) < colSpan)
            {
                for (int i = (RowCount*2); i < colSpan; i++)
                {
                    sb.Append("<td>&nbsp;</td>");
                }
                sb.Append("</tr>");
            }

            return sb.ToString();
        }