Exemplo n.º 1
0
        public void SaveTheGraphOption(string curveRgb, string limitRgb, string rangeRgb
                                       , bool isShowLimit, bool isShowMark, bool isFillRange, string format, bool isConfigTakeEffectNextTime)
        {
            UserProfileBLL      _bll            = new UserProfileBLL();
            IList <UserProfile> allUserProfiles = _bll.GetAllUserProfiles();
            bool result = false;

            if (allUserProfiles != null && allUserProfiles.Count > 0)
            {
                foreach (var item in allUserProfiles)
                {
                    if (item != null && item.ID != 0)
                    {
                        if (CheckRGBFormat(curveRgb))
                        {
                            item.TempCurveRGB = curveRgb;
                        }
                        if (CheckRGBFormat(limitRgb))
                        {
                            item.AlarmLineRGB = limitRgb;
                        }
                        if (CheckRGBFormat(rangeRgb))
                        {
                            item.IdealRangeRGB = rangeRgb;
                        }
                        item.IsShowAlarmLimit = isShowLimit;
                        item.IsShowMark       = isShowMark;
                        item.IsFillIdealRange = isFillRange;
                        item.DateTimeFormator = format;
                        result = _bll.UpdateProfile(item);
                    }
                    if (!result)
                    {
                        break;
                    }
                }
            }
            else
            {
                UserProfile userProfile = new UserProfile();
                userProfile.ID       = _bll.GetProfilePKValue() + 1;
                userProfile.UserName = Common.User.UserName == null ? "" : Common.User.UserName;
                if (CheckRGBFormat(curveRgb))
                {
                    userProfile.TempCurveRGB = curveRgb;
                }
                if (CheckRGBFormat(limitRgb))
                {
                    userProfile.AlarmLineRGB = limitRgb;
                }
                if (CheckRGBFormat(rangeRgb))
                {
                    userProfile.IdealRangeRGB = rangeRgb;
                }
                userProfile.IsShowAlarmLimit = isShowLimit;
                userProfile.IsShowMark       = isShowMark;
                userProfile.IsFillIdealRange = isFillRange;
                userProfile.DateTimeFormator = format;
                userProfile.Remark           = DateTime.Now.ToString();

                userProfile.ContactInfo = "";
                userProfile.Logo        = ShineTech.TempCentre.Platform.Utils.CopyToBinary(Properties.Resources.tempsen);
                userProfile.DefaultPath = "";
                userProfile.ReportTitle = "";

                userProfile.IsGlobal     = (int)GlobalType.None;
                userProfile.IsShowHeader = false;
                userProfile.TempUnit     = "C";
                result = _bll.InsertProfile(userProfile);
            }


            if (result)
            {
                if (isConfigTakeEffectNextTime)
                {
                    Platform.Utils.ShowMessageBox(Platform.Messages.B48, Platform.Messages.TitleNotification, MessageBoxButtons.OK);
                }
                else
                {
                    Platform.Utils.ShowMessageBox(Platform.Messages.B47, Platform.Messages.TitleNotification, MessageBoxButtons.OK);
                }
                Common.GlobalProfile = null;
            }
            else
            {
                Platform.Utils.ShowMessageBox(Platform.Messages.B49, Platform.Messages.TitleNotification, MessageBoxButtons.OK);
            }
        }