public RemoveSelectionCommand(List<Atom> atomsToRemove, List<Binding> bindingsToRemove, ObservableCollection<Atom> atoms, ObservableCollection<Binding> bindings)
        {
            this.atomsToRemove = atomsToRemove;
            this.atoms = atoms;
            this.bindings = bindings;

            List<Binding> additionalBindingsToRemove = new List<Binding>();
            foreach (Binding b in bindings)
            {
                if (atomsToRemove.Contains(b.BindingPoint1) || atomsToRemove.Contains(b.BindingPoint2))
                {
                    additionalBindingsToRemove.Add(b);
                }
            }

            foreach (Binding b in additionalBindingsToRemove)
            {
                if (!bindingsToRemove.Contains(b))
                {
                    bindingsToRemove.Add(b);
                }
            }

            this.bindingsToRemove = bindingsToRemove;
        }
        public static void DelSubject(List<Priority> SP, List<String> SubjectID)
        {
            List<String> SB = new List<String>();
            if (SubjectID != null)
            {
                foreach (var r in SP)
                    if (!SubjectID.Contains(r.SubjectID.ToString()))
                        SB.Add(r.SubjectID);
            }
            else
            {
                foreach (var r in SP)
                    SB.Add(r.SubjectID);
            }

            for (int i = 0; i < SB.Count(); i++)
            {
                var a = SB[i];
                var nhom = (from m in InputHelper.db.nhoms
                            where m.MaMonHoc.Equals(a)
                            select m.Nhom1).ToList();
                foreach (var r in nhom)
                {
                    byte aByte = Convert.ToByte(r);
                    InputHelper.Groups.FirstOrDefault(m => m.Value.MaMonHoc == SB[i] && m.Value.Nhom == aByte).Value.IsIgnored = false;
                }
                OutputHelper.SaveOBJ("Groups", InputHelper.Groups);
            }
        }
Beispiel #3
0
        /// </summary>
        /// <param name="first_verse">First verse in sentence</param>
        /// <param name="start_position">Position in verse of first letter of first word in sentence</param>
        /// <param name="last_verse">Last verse in sentence</param>
        /// <param name="end_position">Position in verse of last letter of last word in sentence</param>
        /// <param name="text">Complete text of sentence within its verse or across multiple verses</param>
        public Sentence(Verse first_verse, int start_position, Verse last_verse, int end_position, string text)
        {
            this.first_verse = first_verse;
            this.start_position = start_position;
            this.last_verse = last_verse;
            this.end_position = end_position;
            this.text = text;

            this.chapter_count = last_verse.Chapter.Number - first_verse.Chapter.Number + 1;
            this.verse_count = last_verse.Number - first_verse.Number + 1;

            string text_mode = first_verse.Book.Title;
            string simplified_text = this.text.SimplifyTo(text_mode);

            this.word_count = simplified_text.Split().Length;

            this.letter_count = simplified_text.Length - word_count + 1;

            List<char> unique_letters = new List<char>();
            foreach (char letter in simplified_text)
            {
                if (letter == ' ') continue;

                if (!unique_letters.Contains(letter))
                {
                    unique_letters.Add(letter);
                }
            }
            this.unique_letter_count = unique_letters.Count;
        }
 private void SelectOnlyCoveredTests(TestsRootNode rootNode, List<MethodIdentifier> coveredTests)
 {
     rootNode.IsIncluded = false;
     var toSelect = rootNode.Children.SelectManyRecursive(n => n.Children, leafsOnly: true)
         .OfType<TestNodeMethod>()
         .Where(t => coveredTests.Contains(t.Identifier));
     foreach (var testNodeMethod in toSelect)
     {
         testNodeMethod.IsIncluded = true;
     }
 }
Beispiel #5
0
        //Getpro cookie
        public List<ESHOP_NEW> Loadpro_cookie(int type, List<string> listnews_url)
        {
            try
            {
                var list=db.ESHOP_NEWs.Where(n=>n.NEWS_TYPE == type&& listnews_url.Contains(n.NEWS_SEO_URL)).Distinct().OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER_PERIOD).ToList();
                return list;

            }
            catch (Exception)
            {

                throw;
            }
        }
Beispiel #6
0
        public static List<string> ListaPaises()
        {
            List<string> ListaCultura = new List<string>();

            CultureInfo[] SelecionarCultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

            foreach (CultureInfo SelecionarCultura in SelecionarCultureInfo)
            {
                RegionInfo SelecionarRegionInfo = new RegionInfo(SelecionarCultura.LCID);
                if (!(ListaCultura.Contains(SelecionarRegionInfo.DisplayName)))
                {
                    ListaCultura.Add(SelecionarRegionInfo.DisplayName);
                }
            }
            ListaCultura.Sort();
            return ListaCultura;
        }
		protected override int GetResults(Viewport viewport)
		{
			switch (this.tableName)
			{
				case "Venue":
					{
						var q = from v in dc.Venues
								from htmIds in dc.FHtmCoverRect(viewport.South, viewport.West, viewport.North, viewport.East)
								where v.HtmId >= htmIds.HtmIDStart && v.HtmId <= htmIds.HtmIDEnd &&
									v.Lat >= viewport.South && v.Lat <= viewport.North &&
									v.Lon >= viewport.West && v.Lon <= viewport.East
								orderby v.K
								select new { v.K };

						using (
							new TransactionScope(TransactionScopeOption.Required,
												 new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }))
						{
							return q.Take(200).ToArray().Length;
						}
					}
				case "Event":
					{
						List<int> allHardDanceMusicTypeKs = new List<int> { 10, 11, 12, 13, 14, 45, 59, 60 };
						var q = from v in dc.Events
								from htmIds in dc.FHtmCoverRect(viewport.South, viewport.West, viewport.North, viewport.East)
								join m in dc.EventMusicTypes on v.K equals m.EventK
								where v.HtmId >= htmIds.HtmIDStart && v.HtmId <= htmIds.HtmIDEnd &&
									v.Lat >= viewport.South && v.Lat <= viewport.North &&
									v.Lon >= viewport.West && v.Lon <= viewport.East
									&& allHardDanceMusicTypeKs.Contains(m.MusicTypeK)
								orderby v.K
								select new { v.K };

						using (
							new TransactionScope(TransactionScopeOption.Required,
												 new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }))
						{
							return q.Take(200).ToArray().Length;
						}
					}
				default:
					throw new NotImplementedException(this.tableName);
			}
		}
Beispiel #8
0
        public override async void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var recipes = await _localDataService.Load("Data\\Recipes.txt");

            var ds = new List<string>();
            RecipeDataGroup group = null;
            foreach (RecipeDataItem recipe in recipes)
            {
                if (!ds.Contains(recipe.Group.UniqueId))
                {
                    group = recipe.Group;
                    group.Items = new ObservableCollection<RecipeDataItem>();
                    ds.Add(recipe.Group.UniqueId);
                    _recipeRepository.ItemGroups.Add(group);
                }

                _recipeRepository.AssignedUserImages(recipe);
                if (group != null) group.Items.Add(recipe);
            }
        }
        public override async Task OnNavigatedTo(NavigationEventArgs e)
        {
            var recipes = await _recipesService.Load("Data\\Recipes.json");
       
            var ds = new List<string>();
            RecipeDataGroup group = null;

            Recipes = new ObservableCollection<RecipeDataItem>();
            foreach (RecipeDataItem recipe in recipes)
            {
                Recipes.Add(recipe);
                if (!ds.Contains(recipe.Group.UniqueId))
                {
                    group = recipe.Group;
                    group.Items = new ObservableCollection<RecipeDataItem>();
                    ds.Add(recipe.Group.UniqueId);
                    _recipeRepository.ItemGroups.Add(group);
                }

                _recipeRepository.AssignedUserImages(recipe);
                if (group != null) group.Items.Add(recipe);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Pushes the version taken as a parameter
        /// Will return any changes that conflicts
        /// IMPORTANT: The version is not commited at the server before null is returned!
        /// </summary>
        /// <param name="path">The path to the repository to push</param>
        /// <param name="number">The version number used to identify the right version</param>
        /// <param name="log">The changes given by a number of text-.</param>
        /// <param name="user">The user to submit changes.</param>
        /// <returns>
        /// Any changes that conflicts or null if version is commited
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Log can't be null</exception>
        /// <exception cref="System.ArgumentException">Log can't be empty</exception>
        public string[][] PushVersion(String path, int number, string[] log, User user)
        {
            if (log == null) throw new ArgumentNullException("Log can't be null");
            if (log.Length < 1) throw new ArgumentException("Log can't be empty");
            if (user == null) throw new ArgumentNullException("User can't be null");
            if (String.IsNullOrEmpty(user.Name)) throw new ArgumentException("User's name is invalid: " + user.Name);
            if (String.IsNullOrEmpty(user.Password)) throw new ArgumentException("User's password is invalid");
            if (user.MAC == null) throw new ArgumentNullException("User's MAC address is invalid (" + user.MAC + " and can therefore not push");

            Console.WriteLine("[" + DateTime.Now + "]: " + "User is pushing to the server: " + user.MAC);

            //See if the user is known - if not: Throw an exception
            //Connect(user);

            var returnArray = new string[0][];

            // Test that the version number is correct - otherwise we'll just store things at the wrong places.
            var vcs = new ServerVersionControlSystem(path, _fileSystem);
            var currentVersion = vcs.GetLatestVersionNumber();
            if (currentVersion != number - 1)
            {
                throw new ArgumentException("Can not push version " + number + " to the server version " + currentVersion);
            }

            // If the last user that attempted to push is the same as the current user, no conflicts will occur.
            if (PushedLastVersion(user))
            {
                // We can assume that everything has been resolved client side and execute all the changes made
                IList<AbstractChange> changeList = ChangeParser.ParseChanges(log).Where(item => item != null).ToList();

                // Store the version
                SaveChanges(number, user, vcs, changeList);
            }
            else
            {
                String[] simpleChanges = SearchForSimpleChanges(log);
                String[,] complexChanges = SearchForComplexChanges(log);
                ISet<String> conflictingPathsOnServerSet = new SortedSet<string>();
                ISet<String> conflictingPathsOnClientSet = new SortedSet<string>();

                //Get paths to all text files in project directory and all sub directories.
                String absolutePath = vcs.GetFileSystemRoot() + path;
                IList<String> projectFilesList = new List<string>(Directory.GetFileSystemEntries(absolutePath, "*", SearchOption.AllDirectories).Where(s => s.Contains(FileSystem.META_DIR) == false));

                // Discover potential conflicts
                for (int i = 0; i < projectFilesList.Count; i++)
                {
                    projectFilesList[i] = projectFilesList[i].Substring(vcs.GetFileSystemRoot().Length);
                }

                foreach (String filePath in simpleChanges)
                {
                    if (projectFilesList.Contains(filePath))
                    {
                        conflictingPathsOnServerSet.Add(filePath);
                        conflictingPathsOnClientSet.Add(filePath);
                    }
                }
                for (int i = 0; i < complexChanges.Length; i++)
                {
                    if (projectFilesList.Contains(complexChanges[i, 0]))
                    {
                        conflictingPathsOnServerSet.Add(complexChanges[i, 0]);
                        conflictingPathsOnClientSet.Add(complexChanges[i, 1]);
                    }
                }

                // If no conflicts arises we can save the change to the file system
                if (conflictingPathsOnServerSet.Count == 0)
                {
                    SaveChanges(number, user, vcs, ChangeParser.ParseChanges(log));
                }
                else // Otherwise we find the conflicting paths and return the contents of the file on the
                // server for the client to merge
                {
                    IList<String> conflictingPathsOnServer = new List<string>(conflictingPathsOnServerSet);
                    IList<String> conflictingPathsOnClient = new List<string>(conflictingPathsOnClientSet);
                    var list = new List<string[]>();
                    for (int i = 0; i < conflictingPathsOnServer.Count; i++)
                    {
                        var fileList = new List<string>() { conflictingPathsOnClient[i] };
                        fileList.AddRange(vcs.ReadAllLines(conflictingPathsOnServer[i]));
                        list.Add(fileList.ToArray());
                    }
                    returnArray = list.ToArray();
                }
            }

            // Save the last MAC adress
            _lastPushUser = user.Name;
            //AddToPushHistory(user);

            // Return the conflicts to the client
            return returnArray;
        }
        /// <summary> 提交时获取当前配件列表中存在的引用单号,保存到中间表中
        /// 并生成执行的sql
        /// </summary>
        /// <returns></returns>
        void GetPre_Order_Code(List<SysSQLString> listSql, string purchase_billing_id, string post_order_id, string post_order_code)
        {
            List<string> list = new List<string>();
            SysSQLString sysStringSql = new SysSQLString();
            sysStringSql.cmdType = CommandType.Text;
            Dictionary<string, string> dic = new Dictionary<string, string>();
            string sql1 = "delete from tr_order_relation where post_order_id=@post_order_id;";
            dic.Add("post_order_id", post_order_id);
            dic.Add("post_order_code", post_order_code);
            sysStringSql.sqlString = sql1;
            sysStringSql.Param = dic;
            listSql.Add(sysStringSql);

            DataTable dt_relation_order = DBHelper.GetTable("查询采购开单配件表的引用单号", "tb_parts_purchase_billing_p", " purchase_billing_id,relation_order ", " purchase_billing_id='" + purchase_billing_id + "'", "", "");
            if (dt_relation_order != null && dt_relation_order.Rows.Count > 0)
            {
                foreach (DataRow dr in dt_relation_order.Rows)
                {
                    string relation_order = dr["relation_order"] == null ? "" : dr["relation_order"].ToString();
                    if (!string.IsNullOrEmpty(relation_order))
                    {
                        if (!list.Contains(relation_order))
                        {
                            list.Add(relation_order);
                            sysStringSql = new SysSQLString();
                            sysStringSql.cmdType = CommandType.Text;
                            dic = new Dictionary<string, string>();
                            dic.Add("order_relation_id", Guid.NewGuid().ToString());
                            dic.Add("pre_order_id", string.Empty);
                            dic.Add("pre_order_code", relation_order);
                            dic.Add("post_order_id", post_order_id);
                            dic.Add("post_order_code", post_order_code);
                            string sql2 = string.Format(@"Insert Into tr_order_relation(order_relation_id,pre_order_id,pre_order_code,
                                                      post_order_id,post_order_code)  values(@order_relation_id,@pre_order_id,
                                                      @pre_order_code,@post_order_id,@post_order_code);");
                            sysStringSql.sqlString = sql2;
                            sysStringSql.Param = dic;
                            listSql.Add(sysStringSql);
                        }
                    }
                }
            }
        }
        private bool VerifyExtensionConfigDiag(ExtensionConfigurationInput resultConfig, string storage, List<string> roles, XmlDocument wadconfig = null, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null)
        {
            try
            {
                string resultStorageAccount = GetInnerText(resultConfig.PublicConfiguration, "Name");
                string resultWadCfg = Utilities.GetInnerXml(resultConfig.PublicConfiguration, "WadCfg");
                if (string.IsNullOrWhiteSpace(resultWadCfg))
                {
                    resultWadCfg = null;
                }
                string resultStorageKey = GetInnerText(resultConfig.PrivateConfiguration, "StorageKey");

                Console.WriteLine("Type: {0}, StorageAccountName:{1}, StorageKey: {2}, WadCfg: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}",
                    resultConfig.Type, resultStorageAccount, resultStorageKey, resultWadCfg, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate);

                Assert.AreEqual(resultConfig.Type, "Diagnostics", "Type is not equal!");
                Assert.AreEqual(resultStorageAccount, storage);
                Assert.IsTrue(Utilities.CompareWadCfg(resultWadCfg, wadconfig));

                if (string.IsNullOrWhiteSpace(thumbprint))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint));
                }
                else
                {
                    Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!");
                }
                if (string.IsNullOrWhiteSpace(algorithm))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm));
                }
                else
                {
                    Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!");
                }
                Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!");
                if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName))
                {
                    Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString()));
                }
                else
                {
                    foreach (ExtensionRole role in resultConfig.Roles)
                    {
                        Assert.IsTrue(roles.Contains(role.RoleName));
                    }
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
        private bool VerifyExtensionConfigRDP(ExtensionConfigurationInput resultConfig, string user, string pass, List<string> roles, DateTime exp, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null)
        {
            try
            {
                string resultUserName = GetInnerText(resultConfig.PublicConfiguration, "UserName");
                string resultPassword = GetInnerText(resultConfig.PrivateConfiguration, "Password");
                string resultExpDate = GetInnerText(resultConfig.PublicConfiguration, "Expiration");

                Console.WriteLine("Type: {0}, UserName:{1}, Password: {2}, ExpirationDate: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}",
                    resultConfig.Type, resultUserName, resultPassword, resultExpDate, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate);

                Assert.AreEqual(resultConfig.Type, "RDP", "Type is not equal!");
                Assert.AreEqual(resultUserName, user);
                Assert.AreEqual(resultPassword, pass);
                Assert.IsTrue(Utilities.CompareDateTime(exp, resultExpDate));

                if (string.IsNullOrWhiteSpace(thumbprint))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint));
                }
                else
                {
                    Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!");
                }

                if (string.IsNullOrWhiteSpace(algorithm))
                {
                    Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm));
                }
                else
                {
                    Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!");
                }
                Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!");
                if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName))
                {
                    Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString()));
                }
                else
                {
                    foreach (ExtensionRole role in resultConfig.Roles)
                    {
                        Assert.IsTrue(roles.Contains(role.RoleName));
                    }
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
Beispiel #14
0
 // get related words and verses
 public List<Word> GetRelatedWords(Word word, bool with_diacritics)
 {
     List<Word> result = new List<Word>();
     if (word != null)
     {
         Dictionary<string, List<Word>> root_words_dictionary = this.RootWords;
         if (root_words_dictionary != null)
         {
             // try all roots in case word_text is a root
             if (root_words_dictionary.ContainsKey(word.Text))
             {
                 List<Word> root_words = root_words_dictionary[word.Text];
                 foreach (Word root_word in root_words)
                 {
                     Verse verse = this.Verses[root_word.Verse.Number - 1];
                     Word verse_word = verse.Words[root_word.NumberInVerse - 1];
                     if (!result.Contains(verse_word))
                     {
                         result.Add(verse_word);
                     }
                 }
             }
             else // if no such root, search for the matching root_word by its verse position and get its root and then get all root_words
             {
                 string root = GetBestRoot(word.Text, with_diacritics);
                 if (!String.IsNullOrEmpty(root))
                 {
                     List<Word> root_words = root_words_dictionary[root];
                     foreach (Word root_word in root_words)
                     {
                         Verse verse = this.Verses[root_word.Verse.Number - 1];
                         Word verse_word = verse.Words[root_word.NumberInVerse - 1];
                         if (!result.Contains(verse_word))
                         {
                             result.Add(verse_word);
                         }
                     }
                 }
             }
         }
     }
     return result;
 }
Beispiel #15
0
        public DataSet GetAlertMaintenance(int organID)
        {
            List<string> list = new List<string>();

            string sql1 = "select FrameNO,max(Kilometre) as Count,min(MaintenanceDate) as MT  from Maintenance where organID = @OrganID group by FrameNO";
            string sql2 = "select FrameNO,max(KM_Count) as Count from Kilometre where organID = @OrganID group by FrameNO";
            SqlParameter[] parameters = {
                    new SqlParameter("@OrganID",organID)
                    };

            DataTable re1 = DbHelperSQL.Query(sql1, parameters).Tables[0];
            DataTable re2 = DbHelperSQL.Query(sql2, parameters).Tables[0];

            DataColumn[] keys = new DataColumn[1];
            keys[0] = re2.Columns["FrameNO"];
            re2.PrimaryKey = keys;

            if (re1 != null || re1.Rows.Count > 0)
            {
                foreach (DataRow dr in re1.Rows)
                {
                    DataRow r = re2.Rows.Find(dr["FrameNO"].ToString());
                    if (r != null)
                    {
                        int x = int.Parse(r["Count"].ToString()) - int.Parse(dr["Count"].ToString());
                        if (x >= 7000)
                        {
                            list.Add(dr["FrameNO"].ToString());
                        }
                    }

                    DateTime mt = DateTime.Parse(dr["MT"].ToString());
                    if (mt.AddMonths(5) < DateTime.Now && !list.Contains(dr["FrameNO"].ToString()))
                    {
                        list.Add(dr["FrameNO"].ToString());
                    }
                }
            }
            if (list.Count > 0)
            {
                string fs = "";
                foreach (string s in list)
                {
                    fs += "'" + s + "',";
                }
                fs = fs.TrimEnd(',');
                string where = " FrameNO in (" + fs + ")";

                return new VehicleDAL().GetList(where);

            }
            else
            {
                return null;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="svc">Service Name</param>
        /// <param name="vm">VM Name</param>
        /// <param name="expStates">An array of expected states. This should not be null</param>
        /// <returns></returns>
        private bool CheckRoleInstanceState(string svc, string vm, string[] expStates)
        {
            List<string> exps = new List<string>(expStates);
            string instanceState = vmPowershellCmdlets.GetAzureVM(vm, svc).InstanceStatus;

            Console.WriteLine("Role instaces: {0}", instanceState);
            return exps.Contains(instanceState);
        }
Beispiel #17
0
        /// <summary> 提交时获取当前配件列表中存在的引用单号,保存到中间表中
        /// 并生成执行的sql
        /// </summary>
        /// <returns></returns>
        void GetPre_Order_Code(List<SysSQLString> listSql, string post_order_id, string post_order_code)
        {
            List<string> list = new List<string>();

            SysSQLString sysStringSql = new SysSQLString();
            sysStringSql.cmdType = CommandType.Text;
            Dictionary<string, string> dic = new Dictionary<string, string>();
            string sql1 = "delete from tr_order_relation where post_order_id=@post_order_id and post_order_code=@post_order_code;";
            dic.Add("post_order_id", post_order_id);
            dic.Add("post_order_code", post_order_code);
            sysStringSql.sqlString = sql1;
            sysStringSql.Param = dic;
            listSql.Add(sysStringSql);

            foreach (DataGridViewRow dr in gvPurchaseList.Rows)
            {
                if (dr.Cells["parts_code"].Value == null)
                {
                    continue;
                }
                string relation_order = dr.Cells["relation_order"].Value == null ? "" : dr.Cells["relation_order"].Value.ToString();
                if (!string.IsNullOrEmpty(relation_order))
                {
                    if (!list.Contains(relation_order))
                    {
                        list.Add(relation_order);

                        sysStringSql = new SysSQLString();
                        sysStringSql.cmdType = CommandType.Text;
                        dic = new Dictionary<string, string>();
                        dic.Add("order_relation_id", Guid.NewGuid().ToString());
                        dic.Add("pre_order_id", string.Empty);
                        dic.Add("pre_order_code", relation_order);
                        dic.Add("post_order_id", post_order_id);
                        dic.Add("post_order_code", post_order_code);
                        string sql2 = string.Format(@"Insert Into tr_order_relation(order_relation_id,pre_order_id,pre_order_code,
                                                      post_order_id,post_order_code)  values(@order_relation_id,@pre_order_id,
                                                      @pre_order_code,@post_order_id,@post_order_code);");
                        sysStringSql.sqlString = sql2;
                        sysStringSql.Param = dic;
                        listSql.Add(sysStringSql);
                    }
                }
            }
        }
        public ActionResult OpenRooms()
        {
            var rooms = (from r in InputHelper.db.This
                         select new
                         {
                             r.MaPhong,
                             r.CaThi.GioThi
                         }).ToList();

            List<string[]> Result = new List<string[]>();
            int stt = 0;
            DateTime StartWeek, EndWeek;
            EndWeek = new DateTime(2012, 1, 1);
            for (int k = 0; k < (InputHelper.Options.NumDate / 7); k++)
            {
                if (k == 0)
                    StartWeek = InputHelper.Options.StartDate;
                else
                    StartWeek = EndWeek.AddDays(2);
                EndWeek = StartWeek.AddDays((OutputHelper.DayOffWeekVN(StartWeek) == "Thứ Hai") ? 5 : (OutputHelper.DayOffWeekVN(StartWeek) == "Thứ Ba") ? 4 : (OutputHelper.DayOffWeekVN(StartWeek) == "Thứ Tư") ? 3 : (OutputHelper.DayOffWeekVN(StartWeek) == "Thứ Năm") ? 2 : (OutputHelper.DayOffWeekVN(StartWeek) == "Thứ Sáu") ? 1 : 0);

                //lọc theo tuần
                var w1 = (from w in rooms
                          where w.GioThi.Date >= StartWeek && w.GioThi.Date <= EndWeek
                          select w).ToList();

                List<string> deny = new List<string>();
                foreach (var r1 in w1)
                    if (!deny.Contains(r1.MaPhong))
                    {
                        deny.Add(r1.MaPhong);
                        Init();
                        string[] s = new string[10];
                        s[0] = ++stt + "";
                        s[1] = StartWeek.ToString("dd/MM/yy") + "-" + EndWeek.ToString("dd/MM/yy");
                        s[2] = r1.MaPhong;

                        foreach (var r2 in w1)
                            if (r2.MaPhong == r1.MaPhong)
                            {
                                DateTime time = r2.GioThi;
                                switch (OutputHelper.DayOffWeekVN(time.Date))
                                {
                                    case "Thứ Hai":
                                        Check(time, 0);
                                        break;
                                    case "Thứ Ba":
                                        Check(time, 1);
                                        break;
                                    case "Thứ Tư":
                                        Check(time, 2);
                                        break;
                                    case "Thứ Năm":
                                        Check(time, 3);
                                        break;
                                    case "Thứ Sáu":
                                        Check(time, 4);
                                        break;
                                    case "Thứ Bảy":
                                        Check(time, 5);
                                        break;
                                }
                            }
                        s[3] = Thu[0, 0].ToString() + Thu[0, 1].ToString() + Thu[0, 2].ToString() + Thu[0, 3].ToString() + Thu[0, 4].ToString() + Thu[0, 5].ToString() + Thu[0, 6].ToString() + Thu[0, 7].ToString() + Thu[0, 8].ToString() + Thu[0, 9].ToString() + Thu[0, 10].ToString() + "";
                        s[4] = Thu[1, 0].ToString() + Thu[1, 1].ToString() + Thu[1, 2].ToString() + Thu[1, 3].ToString() + Thu[1, 4].ToString() + Thu[1, 5].ToString() + Thu[1, 6].ToString() + Thu[1, 7].ToString() + Thu[1, 8].ToString() + Thu[1, 9].ToString() + Thu[1, 10].ToString() + "";
                        s[5] = Thu[2, 0].ToString() + Thu[2, 1].ToString() + Thu[2, 2].ToString() + Thu[2, 3].ToString() + Thu[2, 4].ToString() + Thu[2, 5].ToString() + Thu[2, 6].ToString() + Thu[2, 7].ToString() + Thu[2, 8].ToString() + Thu[2, 9].ToString() + Thu[2, 10].ToString() + "";
                        s[6] = Thu[3, 0].ToString() + Thu[3, 1].ToString() + Thu[3, 2].ToString() + Thu[3, 3].ToString() + Thu[3, 4].ToString() + Thu[3, 5].ToString() + Thu[3, 6].ToString() + Thu[3, 7].ToString() + Thu[3, 8].ToString() + Thu[3, 9].ToString() + Thu[3, 10].ToString() + "";
                        s[7] = Thu[4, 0].ToString() + Thu[4, 1].ToString() + Thu[4, 2].ToString() + Thu[4, 3].ToString() + Thu[4, 4].ToString() + Thu[4, 5].ToString() + Thu[4, 6].ToString() + Thu[4, 7].ToString() + Thu[4, 8].ToString() + Thu[4, 9].ToString() + Thu[4, 10].ToString() + "";
                        s[8] = Thu[5, 0].ToString() + Thu[5, 1].ToString() + Thu[5, 2].ToString() + Thu[5, 3].ToString() + Thu[5, 4].ToString() + Thu[5, 5].ToString() + Thu[5, 6].ToString() + Thu[5, 7].ToString() + Thu[5, 8].ToString() + Thu[5, 9].ToString() + Thu[5, 10].ToString() + "";
                        Result.Add(s);
                    }
            }
            return View(Result);
        }
        /// <summary> 设置选择项后状态
        /// </summary>
        void SetSelectedStatus()
        {
            listIDs.Clear();
            //已选择状态列表
            List<string> listFiles = new List<string>();
            foreach (DataGridViewRow dgvr in gvPurchaseOrderList.Rows)
            {
                if (Convert.ToBoolean(dgvr.Cells[colCheck.Name].EditedFormattedValue))
                {
                    listFiles.Add(dgvr.Cells[order_status.Name].Value.ToString());
                    listIDs.Add(dgvr.Cells[purchase_billing_id.Name].Value.ToString());
                }
            }

            //提交
            string submitStr = ((int)DataSources.EnumAuditStatus.SUBMIT).ToString();
            //审核
            string auditStr = ((int)DataSources.EnumAuditStatus.AUDIT).ToString();
            //草稿
            string draftStr = ((int)DataSources.EnumAuditStatus.DRAFT).ToString();
            //审核未通过
            string noAuditStr = ((int)DataSources.EnumAuditStatus.NOTAUDIT).ToString();
            //作废
            string invalid = ((int)DataSources.EnumAuditStatus.Invalid).ToString();
            //复制按钮,只选择一个并且不是作废,可以复制
            if (listFiles.Count == 1 && !listFiles.Contains(invalid))
            {
                btnCopy.Enabled = true;
            }
            else
            {
                btnCopy.Enabled = false;
            }
            //编辑按钮,只选择一个并且是草稿或未通过状态,可以编辑
            if (listFiles.Count == 1 && (listFiles.Contains(draftStr) || listFiles.Contains(noAuditStr)))
            {
                btnEdit.Enabled = true;
                //tsmiEdit.Enabled = true;
            }
            else
            {
                btnEdit.Enabled = false;
                //tsmiEdit.Enabled = false;
            }
            //判断”审核“按钮是否可用
            if (listFiles.Contains(auditStr) || listFiles.Contains(draftStr) || listFiles.Contains(noAuditStr) || listFiles.Contains(invalid))
            {
                btnVerify.Enabled = false;
                //tsmiVerify.Enabled = false;
            }
            else
            {
                btnVerify.Enabled = true;
                //tsmiVerify.Enabled = true;
            }
            //包含已审核、已提交、已作废状态,提交、删除按钮不可用
            if (listFiles.Contains(auditStr) || listFiles.Contains(submitStr) || listFiles.Contains(invalid))
            {
                btnSubmit.Enabled = false;
                btnDelete.Enabled = false;
                //tsmiSubmit.Enabled = false;
                //tsmiDelete.Enabled = false;
            }
            else
            {
                btnSubmit.Enabled = true;
                btnDelete.Enabled = true;
                //tsmiSubmit.Enabled = true;
                //tsmiDelete.Enabled = true;
            }

            if (listFiles.Contains(invalid))
            {

            }
        } 
Beispiel #20
0
        /// <summary>
        /// Get verses with ALL their words used inside the parameter "words".
        /// Verses with some words used in the parameter "words" are not returned.  
        /// </summary>
        /// <param name="words"></param>
        /// <returns></returns>
        public List<Verse> GetVerses(List<Word> words)
        {
            List<Verse> result = new List<Verse>();
            Verse verse = null;
            foreach (Word word in words)
            {
                if (verse != word.Verse)
                {
                    verse = word.Verse;
                    if (!result.Contains(verse))
                    {
                        bool include_verse = true;
                        foreach (Word verse_word in verse.Words)
                        {
                            if (!words.Contains(verse_word))
                            {
                                include_verse = false;
                                break;
                            }
                        }

                        if (include_verse)
                        {
                            result.Add(verse);
                        }
                    }
                }
            }
            return result;
        }
 public List<ESHOP_CATEGORy> Load_xuatxu(string cat_seo)
 {
     if (checkXuatxu(cat_seo))
     {
         var list = db.ESHOP_CATEGORies.Where(n => n.CAT_SEO_URL == cat_seo).ToList();
         if (list.Count > 0)
         {
             List<int> listhsx = new List<int>();
             int _catid = 0;
             var getallHsx = (from a in db.ESHOP_NEWs
                              join b in db.ESHOP_NEWS_CATs on a.NEWS_ID equals b.NEWS_ID
                              where a.UNIT_ID1 == list[0].CAT_ID
                              select new { b.CAT_ID, b.ESHOP_CATEGORy.CAT_RANK, b.ESHOP_CATEGORy.CAT_PARENT_PATH }).Distinct().ToList();
             if (getallHsx.Count > 0)
             {
                 if (getallHsx[0].CAT_RANK > 1)
                 {
                     string[] a = getallHsx[0].CAT_PARENT_PATH.Split(',');
                     _catid = Utils.CIntDef(a[1]);
                 }
                 else _catid = Utils.CIntDef(getallHsx[0].CAT_ID);
             }
             var getall = (from a in db.ESHOP_NEWS_CATs
                           join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                           join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                           where c.CAT_ID == _catid || c.CAT_PARENT_PATH.Contains(_catid.ToString())
                           select new { b.UNIT_ID1 }).Distinct();
             foreach (var i in getall)
             {
                 listhsx.Add(Utils.CIntDef(i.UNIT_ID1));
             }
             var gethsx = db.ESHOP_CATEGORies.Where(n => listhsx.Contains(n.CAT_ID)).ToList();
             return gethsx;
         }
         return new List<ESHOP_CATEGORy>();
     }
     else if (checkHangsx(cat_seo))
     {
         var list = db.ESHOP_CATEGORies.Where(n => n.CAT_SEO_URL == cat_seo).ToList();
         if (list.Count > 0)
         {
             List<int> listhsx = new List<int>();
             int _catid = 0;
             var getallHsx = (from a in db.ESHOP_NEWs
                              join b in db.ESHOP_NEWS_CATs on a.NEWS_ID equals b.NEWS_ID
                              where a.UNIT_ID2 == list[0].CAT_ID
                              select new { b.CAT_ID, b.ESHOP_CATEGORy.CAT_RANK, b.ESHOP_CATEGORy.CAT_PARENT_PATH }).Distinct().ToList();
             if (getallHsx.Count > 0)
             {
                 if (getallHsx[0].CAT_RANK > 1)
                 {
                     string[] a = getallHsx[0].CAT_PARENT_PATH.Split(',');
                     _catid = Utils.CIntDef(a[1]);
                 }
                 else _catid = Utils.CIntDef(getallHsx[0].CAT_ID);
             }
             var getall = (from a in db.ESHOP_NEWS_CATs
                           join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                           join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                           where c.CAT_ID == _catid || c.CAT_PARENT_PATH.Contains(_catid.ToString())
                           select new { b.UNIT_ID1 }).Distinct();
             foreach (var i in getall)
             {
                 listhsx.Add(Utils.CIntDef(i.UNIT_ID1));
             }
             var gethsx = db.ESHOP_CATEGORies.Where(n => listhsx.Contains(n.CAT_ID)).ToList();
             return gethsx;
         }
         return new List<ESHOP_CATEGORy>();
     }
     else
     {
         List<int> idcat = new List<int>();
         var getcatid = db.ESHOP_CATEGORies.Where(n => n.CAT_SEO_URL == cat_seo).Select(n => new { n.CAT_ID }).ToList();
         if (getcatid.Count > 0)
         {
             var list = (from a in db.ESHOP_NEWs
                         join b in db.ESHOP_NEWS_CATs on a.NEWS_ID equals b.NEWS_ID
                         where b.ESHOP_CATEGORy.CAT_ID == getcatid[0].CAT_ID || b.ESHOP_CATEGORy.CAT_PARENT_PATH.Contains(getcatid[0].CAT_ID.ToString())
                         select new { a.UNIT_ID1 }).Distinct();
             foreach (var i in list)
             {
                 idcat.Add(Utils.CIntDef(i.UNIT_ID1));
             }
         }
         var getlisthsx = db.ESHOP_CATEGORies.Where(n => idcat.Contains(n.CAT_ID)).ToList();
         return getlisthsx;
     }
 }
        public List<ESHOP_CATEGORy> Load_Shop(string cat_seo)
        {
            var list = (from a in db.ESHOP_NEWS_CATs
                        join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                        join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                        join d in db.ESHOP_SHOPs on b.SHOP_ID equals d.ID
                        where d.SEO_URL == cat_seo
                        select c).Distinct().ToList();

            List<int> idcat = new List<int>();
            foreach (var i in list)
            {
                int id = i.CAT_ID;
                var item = db.ESHOP_CATEGORies.Where(n => n.CAT_ID == i.CAT_PARENT_ID && i.CAT_PARENT_ID > 0).ToList();
                if (item != null && item.ToList().Count > 0)
                {
                    id = item.ToList()[0].CAT_ID;
                    var item2 = db.ESHOP_CATEGORies.Where(n => n.CAT_ID == item.ToList()[0].CAT_PARENT_ID && item.ToList()[0].CAT_PARENT_ID > 0).ToList();
                    if (item2 != null && item2.ToList().Count > 0)
                    {
                        id = item2.ToList()[0].CAT_ID;
                        var item3 = db.ESHOP_CATEGORies.Where(n => n.CAT_ID == item2.ToList()[0].CAT_PARENT_ID && item2.ToList()[0].CAT_PARENT_ID > 0).ToList();
                        if (item3 != null && item3.ToList().Count > 0)
                        {
                            id = item3.ToList()[0].CAT_ID;
                            var item4 = db.ESHOP_CATEGORies.Where(n => n.CAT_ID == item3.ToList()[0].CAT_PARENT_ID && item3.ToList()[0].CAT_PARENT_ID > 0).ToList();
                            if (item4 != null && item4.ToList().Count > 0)
                            {
                                id = item4.ToList()[0].CAT_ID;
                            }
                        }
                    }
                }                

                idcat.Add(id);
            }
            var getlistshop = db.ESHOP_CATEGORies.Where(n => idcat.Contains(n.CAT_ID)).ToList();
            return getlistshop;
        }
 public List<ESHOP_CATEGORy> Load_hangsx(string cat_seo)
 {
     if (checkHangsx(cat_seo))
     { 
         return new List<ESHOP_CATEGORy>();
     }
     else
     {
         List<int> idcat = new List<int>();
         var getcatid = db.ESHOP_CATEGORies.Where(n => n.CAT_SEO_URL == cat_seo).Select(n => new { n.CAT_ID }).ToList();
         if (getcatid.Count > 0)
         {
             var list = (from a in db.ESHOP_NEWs
                         join b in db.ESHOP_NEWS_CATs on a.NEWS_ID equals b.NEWS_ID
                         where b.ESHOP_CATEGORy.CAT_ID == getcatid[0].CAT_ID || b.ESHOP_CATEGORy.CAT_PARENT_PATH.Contains(getcatid[0].CAT_ID.ToString())
                         select new { a.UNIT_ID2 }).Distinct();
             foreach (var i in list)
             {
                 idcat.Add(Utils.CIntDef(i.UNIT_ID2));
             }
         }
         var getlisthsx = db.ESHOP_CATEGORies.Where(n => idcat.Contains(n.CAT_ID)).ToList();
         return getlisthsx;
     }
 }
        public List<ESHOP_CATEGORy> Load_danhmuc_left(string cat_seo,int _catid)
        {

            if (checkHangsx(cat_seo))
            {
                List<int> lcat_id = new List<int>();
                var getListid = (from a in db.ESHOP_NEWs
                                 join b in db.ESHOP_NEWS_CATs on a.NEWS_ID equals b.NEWS_ID
                                 where a.UNIT_ID2 == _catid
                                 select new { b.ESHOP_CATEGORy.CAT_ID }).Distinct();
                foreach (var i in getListid)
                {
                    lcat_id.Add(Utils.CIntDef(i.CAT_ID));
                }
                List<int> lcatid_menu=new List<int>();
                var list = db.ESHOP_CATEGORies.Where(n => lcat_id.Contains(n.CAT_ID)).ToList();
                foreach (var i in list)
                {
                    if (i.CAT_RANK > 2)
                    {
                        string[] a = i.CAT_PARENT_PATH.Split(',');
                        lcatid_menu.Add(Utils.CIntDef(a[2]));
                    }
                    else lcatid_menu.Add(i.CAT_ID);
                }
                var getdata = db.ESHOP_CATEGORies.Where(n => lcatid_menu.Contains(n.CAT_ID)&&n.CAT_TYPE==1).ToList();
                return getdata;
               
            }   
            else
            {
                var list = db.ESHOP_CATEGORies.Where(n => n.CAT_SEO_URL == cat_seo).ToList();
                if (list.Count > 0)
                {
                    if (list[0].CAT_RANK > 1)
                    {
                        string[] a = list[0].CAT_PARENT_PATH.Split(',');
                        int id = Utils.CIntDef(a[1]);
                        var getlistcap1 = db.ESHOP_CATEGORies.Where(n => n.CAT_ID == id).ToList();
                        return getlistcap1;
                    }
                    return list;
                }
            }
            return new List<ESHOP_CATEGORy>();
        }
        //Getpro cookie
        public List<Pro_details_entity> Loadpro_cookie(int type, List<string> listnews_url)
        {
            try
            {
                List<Pro_details_entity> l = new List<Pro_details_entity>();
                var list = (from a in db.ESHOP_NEWS_CATs
                            join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                            join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                            where b.NEWS_TYPE == type && listnews_url.Contains(b.NEWS_SEO_URL)
                            select new { b.NEWS_ID, b.NEWS_TITLE, b.NEWS_IMAGE1, b.NEWS_IMAGE3, b.NEWS_PRICE1, b.NEWS_PRICE2, b.NEWS_DESC, b.NEWS_SEO_URL, b.NEWS_URL, b.NEWS_ORDER_PERIOD, b.NEWS_PUBLISHDATE, c.CAT_SEO_URL }).OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER_PERIOD).ToList();
                foreach (var i in list)
                {
                    Pro_details_entity pro = new Pro_details_entity();
                    pro.NEWS_ID = i.NEWS_ID;
                    pro.NEWS_TITLE = i.NEWS_TITLE;
                    pro.NEWS_IMAGE1 = i.NEWS_IMAGE1;
                    pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
                    pro.NEWS_DESC = i.NEWS_DESC;
                    pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
                    pro.NEWS_URL = i.NEWS_URL;
                    pro.NEWS_PRICE1 = Utils.CDecDef(i.NEWS_PRICE1);
                    pro.NEWS_PRICE2 = Utils.CDecDef(i.NEWS_PRICE2);
                    pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
                    pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
                    pro.CAT_SEO_URL = i.CAT_SEO_URL;
                    l.Add(pro);
                }
                return l;

            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 非批量保存配件信息
        /// </summary>
        /// <param name="partArr">配件信息</param>
        /// <param name="updateCount">更新条数</param>
        /// <returns></returns>
        private static bool SavePartNotBatch(QueryPart.part[] partArr, ref int updateCount)
        {
            long nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime);
            int partIndex = 0;//列表索引
            int partCount = 10000;//每批执行条数
            int partSum = partArr.Count() / partCount + 1;//执行批数
            //partSum = 0;
            bool flag = true;//执行结果
            DateTime startDate = DateTime.Now;
            YuTongDic dic = new YuTongDic();
            //配件
            DataTable dtParts = DBHelper.GetTable("配件信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts", "car_parts_code,parts_id",
                string.Format("data_source='{0}'", (int)DataSources.EnumDataSources.YUTONG), null, null);
            Dictionary<string, string> dicParts = new Dictionary<string, string>();
            foreach (DataRow dr in dtParts.Rows)
            {
                dicParts.Add(dr["car_parts_code"].ToString(), dr["parts_id"].ToString());
            }
            //配件替代信息
            DataTable dtReplace = DBHelper.GetTable("配件替代信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_replace", "parts_id,repl_id", null, null, null);
            //Dictionary<string, string> dicReplace = new Dictionary<string, string>();
            List<string> listReplace = new List<string>();
            foreach (DataRow dr in dtReplace.Rows)
            {
                //dicReplace.Add(dr["repl_id"].ToString(), dr["parts_id"].ToString());
                listReplace.Add(string.Format("{0},{1}", dr["repl_id"], dr["parts_id"]));
            }
            CodingRule comm = new CodingRule(DataSources.EnumProjectType.Parts);
            string partCode = string.Empty;//配件编码
            #region 生成表列
            //配件表
            List<DataRow> listTbParts = new List<DataRow>();
            DataTable dtTbParts = new DataTable();
            dtTbParts.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("ser_parts_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("car_parts_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("parts_name", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("sales_unit_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("data_source", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("default_unit", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("sales_unit_name", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("model", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("retail", typeof(decimal)));
            dtTbParts.Columns.Add(new DataColumn("price3a_back", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("price2a_back", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("status", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dtTbParts.Columns.Add("parts_type", typeof(string));
            dtTbParts.Columns.Add(new DataColumn("base_unit_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("base_unit_name", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("sales_unit_quantity", typeof(int)));
            dtTbParts.Columns.Add(new DataColumn("base_unit_quantity", typeof(int)));
            dtTbParts.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("create_time", typeof(long)));
            //配件价格信息
            DataTable dtTbPartsPrice = new DataTable();
            List<DataRow> listTbPrice = new List<DataRow>();
            dtTbPartsPrice.Columns.Add(new DataColumn("pp_id", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbPartsPrice.Columns.Add("is_stock", typeof(string));
            dtTbPartsPrice.Columns.Add("is_purchase", typeof(string));
            dtTbPartsPrice.Columns.Add("is_sale", typeof(string));
            dtTbPartsPrice.Columns.Add(new DataColumn("unit", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("ref_out_price", typeof(decimal)));
            dtTbPartsPrice.Columns.Add(new DataColumn("out_price_two", typeof(decimal)));
            dtTbPartsPrice.Columns.Add(new DataColumn("out_price_three", typeof(decimal)));
            dtTbPartsPrice.Columns.Add("sort_index", typeof(string));
            dtTbPartsPrice.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("create_time", typeof(long)));
            //替换配件表
            DataTable dtTbReplace = new DataTable();
            List<DataRow> listTbReplace = new List<DataRow>();
            dtTbReplace.Columns.Add(new DataColumn("replace_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_parts_code", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_parts_status", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_remark", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("change", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("create_time", typeof(long)));
            //单位设置
            DataTable dtTbPartsSetup = new DataTable();
            List<DataRow> listTbSetup = new List<DataRow>();
            dtTbPartsSetup.Columns.Add(new DataColumn("set_id", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("stock_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("purchase_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("sale_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("stock_purchase", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("purchase_sale", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("create_time", typeof(long)));
            dtTbPartsSetup.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            #endregion
            for (int i = 0; i < partSum; i++)
            {
                List<SysSQLString> list = new List<SysSQLString>();
                dtTbParts.Rows.Clear();
                dtTbReplace.Rows.Clear();
                listTbParts.Clear();
                listTbReplace.Clear();
                listTbPrice.Clear();
                listTbSetup.Clear();
                for (int y = partIndex; y < partCount; y++)
                {
                    int index = i * partCount + y;
                    if (index >= partArr.Count())
                    {
                        break;
                    }
                    #region 配件信息
                    QueryPart.part item = partArr[index];

                    string price3a = WebServUtil.GetEncField(item.price3a);//加密
                    string price2a = WebServUtil.GetEncField(item.price2a);//加密
                    string partType = dic.GetLocalDicID("part_type", item.part_type);//配件类型
                    string partsID = null;
                    bool isAdd = false;//是否新增
                    if (dicParts.ContainsKey(item.car_parts_code))
                    {
                        partsID = dicParts[item.car_parts_code];
                    }
                    if (!string.IsNullOrEmpty(partsID))
                    {
                        #region 更新语句
                        SysSQLString sysSQLString = new SysSQLString();
                        sysSQLString.cmdType = CommandType.Text;
                        sysSQLString.Param = new Dictionary<string, string>();
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append(" update tb_parts set ");
                        strSql.AppendFormat(" parts_name = '{0}' , ", item.parts_name);
                        strSql.AppendFormat(" sales_unit_code = '{0}' , ", item.unit_code);
                        strSql.AppendFormat(" sales_unit_name = '{0}' , ", item.unit_name);
                        strSql.AppendFormat(" model = '{0}' , ", item.model);
                        strSql.AppendFormat(" status = '{0}' , ", item.status == "0" ? "1" : "0");
                        strSql.AppendFormat(" retail = '{0}' , ", item.retail);
                        strSql.AppendFormat(" price3a = {0} , ", price3a);
                        strSql.AppendFormat(" price2a = {0} , ", price2a);
                        strSql.AppendFormat(" parts_type='{0}',", partType);
                        strSql.AppendFormat(" base_unit_code = '{0}' , ", item.basic_unit_code);
                        strSql.AppendFormat(" base_unit_name = '{0}' , ", item.basic_unit_name);
                        if (!string.IsNullOrEmpty(item.unit_name_quantity))
                        {
                            strSql.AppendFormat(" sales_unit_quantity = {0} , ", item.unit_name_quantity);
                        }
                        if (!string.IsNullOrEmpty(item.basic_unit_quantity))
                        {
                            strSql.AppendFormat(" base_unit_quantity = {0} , ", item.basic_unit_quantity);
                        }
                        strSql.AppendFormat(" enable_flag = '{0}' ,", (int)DataSources.EnumEnableFlag.USING);
                        strSql.AppendFormat(" data_source = '{0}' ,", (int)DataSources.EnumDataSources.YUTONG);
                        strSql.AppendFormat(" update_time = {0} ,", nowTicks);
                        strSql.AppendFormat(" update_by = '{0}' ", GlobalStaticObj_Server.Instance.UserID);
                        strSql.AppendFormat(" where car_parts_code='{0}';  ", item.car_parts_code);
                        sysSQLString.sqlString = strSql.ToString();
                        list.Add(sysSQLString);
                        #endregion
                    }
                    else
                    {
                        isAdd = true;
                        #region 插入语句
                        partsID = Guid.NewGuid().ToString();
                        //strSql.Append(" insert into tb_parts(");
                        //strSql.Append("parts_id,car_parts_code,parts_name,sales_unit_code,data_source,sales_unit_name,model,retail,price3a,price2a,status,enable_flag,base_unit_code,base_unit_name,sales_unit_quantity,base_unit_quantity,create_by,create_time");
                        //strSql.Append(") values (");
                        //strSql.AppendFormat("'{0}',", partsID);
                        //strSql.AppendFormat("'{0}',", item.car_parts_code);
                        //strSql.AppendFormat("'{0}',", item.parts_name);
                        //strSql.AppendFormat("'{0}',", item.unit_code);
                        //strSql.AppendFormat("'{0}',", (int)DataSources.EnumDataSources.YUTONG);
                        //strSql.AppendFormat("'{0}',", item.unit_name);
                        //strSql.AppendFormat("'{0}',", item.model);
                        //strSql.AppendFormat("'{0}',", item.retail);
                        //strSql.AppendFormat("{0},", price3a);
                        //strSql.AppendFormat("{0},", price2a);
                        //strSql.AppendFormat("'{0}',", item.status);
                        //strSql.AppendFormat("'{0}',", (int)DataSources.EnumEnableFlag.USING);
                        //strSql.AppendFormat("'{0}',", item.basic_unit_code);
                        //strSql.AppendFormat("'{0}',", item.basic_unit_name);
                        //strSql.AppendFormat("'{0}',", item.unit_name_quantity);
                        //strSql.AppendFormat("'{0}',", item.basic_unit_quantity);
                        //strSql.AppendFormat("'{0}',", GlobalStaticObj_Server.Instance.ClientID);
                        //strSql.AppendFormat("{0})", nowTicks);
                        //DataRow dr = dtParts.NewRow();
                        //dr["parts_id"] = partsID;
                        //dr["car_parts_code"] = item.car_parts_code;
                        //dtParts.Rows.Add(dr);
                        dicParts.Add(item.car_parts_code, partsID);
                        partCode = comm.AddNewNo();
                        DataRow drParts = dtTbParts.NewRow();
                        drParts["parts_id"] = partsID;
                        drParts["ser_parts_code"] = partCode;
                        drParts["car_parts_code"] = item.car_parts_code;
                        drParts["parts_name"] = item.parts_name;
                        drParts["sales_unit_code"] = item.unit_code;
                        drParts["data_source"] = ((int)DataSources.EnumDataSources.YUTONG).ToString();
                        drParts["default_unit"] = item.unit_name;
                        drParts["sales_unit_name"] = item.unit_name;
                        drParts["model"] = item.model;
                        if (!string.IsNullOrEmpty(item.retail))
                        {
                            drParts["retail"] = Convert.ToDecimal(item.retail);
                        }
                        drParts["price3a_back"] = item.price3a;
                        drParts["price2a_back"] = item.price2a;
                        drParts["parts_type"] = partType;
                        drParts["status"] = item.status == "0" ? "1" : "0";
                        drParts["enable_flag"] = ((int)DataSources.EnumEnableFlag.USING).ToString();
                        drParts["base_unit_code"] = item.basic_unit_code;
                        drParts["base_unit_name"] = item.basic_unit_name;
                        if (!string.IsNullOrEmpty(item.unit_name_quantity))
                        {
                            drParts["sales_unit_quantity"] = (int)Convert.ToDecimal(item.unit_name_quantity);
                        }
                        if (!string.IsNullOrEmpty(item.basic_unit_quantity))
                        {
                            drParts["base_unit_quantity"] = (int)Convert.ToDecimal(item.basic_unit_quantity);
                        }
                        drParts["create_by"] = GlobalStaticObj_Server.Instance.UserID;
                        drParts["create_time"] = nowTicks;
                        listTbParts.Add(drParts);
                        //dtTbParts.Rows.Add(drParts);

                        #endregion
                    }

                    #endregion

                    #region 替代配件
                    foreach (QueryPart.replaceDetail itemReplace in item.partReplace)
                    {
                        if (!dicParts.ContainsKey(item.car_parts_code) || dicParts.ContainsKey(itemReplace.repl_parts_code)
                            || string.IsNullOrEmpty(itemReplace.repl_parts_code))
                        {
                            continue;
                        }
                        string partid = dicParts[item.car_parts_code];
                        string replacepartid = dicParts[itemReplace.repl_parts_code];
                        if (listReplace.Contains(string.Format("{0},{1}", replacepartid, partid)))
                        {
                            #region 更新语句
                            SysSQLString sysSQLString0 = new SysSQLString();
                            sysSQLString0.cmdType = CommandType.Text;
                            sysSQLString0.Param = new Dictionary<string, string>();
                            StringBuilder strSql0 = new StringBuilder();
                            strSql0.Append(" update tb_parts_replace set ");
                            strSql0.AppendFormat(" repl_parts_code = '{0}' , ", itemReplace.repl_parts_code);
                            strSql0.AppendFormat(" repl_parts_status = '{0}' , ", itemReplace.repl_parts_status);
                            strSql0.AppendFormat(" repl_remark = '{0}' , ", itemReplace.repl_remark);
                            strSql0.AppendFormat(" change = '{0}' ", itemReplace.change);
                            strSql0.AppendFormat(" update_time = {0} ", nowTicks);
                            strSql0.AppendFormat(" update_by = '{0}' ", GlobalStaticObj_Server.Instance.UserID);
                            strSql0.AppendFormat(" where parts_id='{0}' and repl_id='{1}'", partid, replacepartid);
                            list.Add(sysSQLString0);
                            #endregion
                        }
                        else
                        {
                            #region 插入语句
                            replacepartid = Guid.NewGuid().ToString();
                            //strSql0.Append(" insert into tb_parts_replace(");
                            //strSql0.Append("replace_id,parts_id,repl_id,repl_parts_code,repl_parts_status,repl_remark,change,create_by,create_time");
                            //strSql0.Append(") values (");
                            //strSql0.AppendFormat("'{0}',", replacepartid);
                            //strSql0.AppendFormat("'{0}',", partid);
                            //strSql0.AppendFormat("'{0}',", Guid.NewGuid());
                            //strSql0.AppendFormat("'{0}',", itemReplace.repl_parts_code);
                            //strSql0.AppendFormat("'{0}',", itemReplace.repl_parts_status);
                            //strSql0.AppendFormat("'{0}',", itemReplace.repl_remark);
                            //strSql0.AppendFormat("'{0}',", itemReplace.change);
                            //strSql0.AppendFormat("'{0}',", GlobalStaticObj_Server.Instance.ClientID);
                            //strSql0.AppendFormat("{0})", nowTicks);
                            //DataRow dr = dtReplace.NewRow();
                            //dr["parts_id"] = partid;
                            //dr["repl_id"] = replacepartid;
                            //dtReplace.Rows.Add(dr);
                            listReplace.Add(string.Format("{0},{1}", replacepartid, partid));

                            DataRow drReplace = dtTbReplace.NewRow();
                            drReplace["replace_id"] = replacepartid;
                            drReplace["parts_id"] = partid;
                            drReplace["repl_id"] = Guid.NewGuid().ToString();
                            drReplace["repl_parts_code"] = itemReplace.repl_parts_code;
                            drReplace["repl_parts_status"] = itemReplace.repl_parts_status;
                            drReplace["repl_remark"] = itemReplace.repl_remark;
                            drReplace["change"] = itemReplace.change;
                            drReplace["create_by"] = GlobalStaticObj_Server.Instance.UserID;
                            drReplace["create_time"] = nowTicks;
                            //dtTbReplace.Rows.Add(drReplace);
                            listTbReplace.Add(drReplace);
                            #endregion
                        }
                    }
                    #endregion

                    #region 配件价格信息
                    if (!isAdd)
                    {
                        DataRow drPrice = dtTbPartsPrice.NewRow();
                        drPrice["pp_id"] = Guid.NewGuid().ToString();
                        drPrice["parts_id"] = partsID;
                        drPrice["unit"] = item.unit_name;
                        drPrice["is_stock"] = "0";
                        drPrice["is_purchase"] = "0";
                        drPrice["is_sale"] = "1";
                        if (!string.IsNullOrEmpty(item.retail))
                        {
                            drPrice["ref_out_price"] = Convert.ToDecimal(item.retail);//参考售价
                        }
                        if (!string.IsNullOrEmpty(item.price2a))
                        {
                            drPrice["out_price_two"] = Convert.ToDecimal(item.price2a);
                        }
                        if (!string.IsNullOrEmpty(item.price3a))
                        {
                            drPrice["out_price_three"] = Convert.ToDecimal(item.price3a);
                        }
                        drPrice["sort_index"] = "0";
                        drPrice["enable_flag"] = ((int)DataSources.EnumEnableFlag.USING).ToString();
                        drPrice["create_by"] = GlobalStaticObj_Server.Instance.UserID;
                        drPrice["create_time"] = nowTicks;
                        listTbPrice.Add(drPrice);
                    }
                    #endregion
                    partArr[index] = null;//释放项
                }

                //flag = DBHelper.BatchExeSQLStringMultiByTrans("宇通:同步配件", list);
                //flag = DBHelper.BatchExeSQLStringMultiByTrans("tb_parts", listTbParts);

                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步配件", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts", listTbParts);
                if (!flag)
                {
                    break;
                }
                #region 更新配件编码
                List<SysSQLString> listUpCode = new List<SysSQLString>();
                SysSQLString sqlCode = new SysSQLString();
                sqlCode.cmdType = CommandType.Text;
                sqlCode.Param = new Dictionary<string, string>();
                sqlCode.Param.Add("bill_code_rule_id", comm.ruleID);
                sqlCode.Param.Add("last_bill_no", partCode);
                sqlCode.sqlString = "update sys_bill_code_rule set last_bill_no=@last_bill_no where bill_code_rule_id=@bill_code_rule_id";
                listUpCode.Add(sqlCode);
                flag = DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("", GlobalStaticObj_Server.Instance.MainAccCode, listUpCode);
                if (!flag)
                {
                    break;
                }
                #endregion
                //flag = DBHelper.BatchExeSQLStringMultiByTrans("tb_parts_replace", listTbReplace);
                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步替换配件", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_replace", listTbReplace);
                if (!flag)
                {
                    break;
                }
                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步价格信息", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_price", listTbPrice);
                if (!flag)
                {
                    break;
                }
                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步单位设置", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_setup", listTbSetup);
                if (list.Count > 0)
                {
                    flag = DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("更新配件信息", GlobalStaticObj_Server.Instance.MainAccCode, list);
                    if (!flag)
                    {
                        break;
                    }
                }

            }
            #region 加密价格
            List<SysSQLString> listUp = new List<SysSQLString>();
            SysSQLString sqlPrice = new SysSQLString();
            sqlPrice.cmdType = CommandType.Text;
            string price3aEnc = WebServUtil.GetEncFieldByField("price3a_back");
            string price2aEnc = WebServUtil.GetEncFieldByField("price2a_back");
            sqlPrice.sqlString = string.Format("update tb_parts set price3a={0},price2a={1},price2a_back=null,price3a_back=null where price3a_back is not null or price2a_back is not null",
                price2aEnc, price2aEnc);
            sqlPrice.Param = new Dictionary<string, string>();
            listUp.Add(sqlPrice);
            DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("", GlobalStaticObj_Server.Instance.MainAccCode, listUp);
            #endregion

            SysConfig sysConfig = new SysConfig();
            sysConfig.UpdateLastTime("PartLastTime");
            updateCount += partArr.Count();
            dtParts = null;
            dtReplace = null;
            dtTbParts = null;
            dtTbPartsPrice = null;
            dtTbPartsSetup = null;
            dtTbReplace = null;
            dic = null;
            DateTime endDate = DateTime.Now;
            TimeSpan span = endDate - startDate;

            return flag;
        }
        private void WaitForStatus(string svcName, string vmName, string[] expStatus, string[] skipStatus, int interval, int maxTry)
        {
            string vmStatus = string.Empty;

            List<string> exps = new List<string>(expStatus);
            List<string> skips = null;
            if (skipStatus != null)
            {
                skips = new List<string>(skipStatus);
            }


            for (int i = 0; i < maxTry; i++)
            {
                vmStatus = vmPowershellCmdlets.GetAzureVM(vmName, svcName).InstanceStatus;

                if (exps.Contains(vmStatus))
                {
                    Console.WriteLine("The VM is in {0} state after {1} seconds", vmStatus, i * interval);
                    return;
                }
                else if (skips == null || skips.Contains(vmStatus))
                {
                    Console.WriteLine("Current VM state is {0}.  Keep waiting...", vmStatus);
                    Thread.Sleep(interval * 1000);
                }
                else
                {
                    Console.WriteLine("Role status is {0}", vmStatus);
                    Assert.Fail("The VM does not become ready.");
                }
            }

            Console.WriteLine("Role status is still {0} after {1} seconds", vmStatus, interval * maxTry);
            Assert.Fail("The VM does not become ready within a given time.");
        }
        //Load random
        public List<Pro_details_entity> loadPro_Random(string _new_seo,int limit)
        {
            List<int> lpos = new List<int>();
            List<Pro_details_entity> l = new List<Pro_details_entity>();
            Random rdom = new Random();
            var getallList = (from a in db.ESHOP_NEWS_CATs
                        join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
                        join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
                              where b.NEWS_SEO_URL!=_new_seo && b.NEWS_TYPE==1
                        select new { b.NEWS_ID, b.NEWS_TITLE, b.NEWS_IMAGE3, b.NEWS_PRICE1, b.NEWS_PRICE2, b.NEWS_DESC, b.NEWS_SEO_URL, b.NEWS_URL, b.NEWS_ORDER, b.NEWS_ORDER_PERIOD, b.NEWS_PUBLISHDATE, b.NEWS_CODE, b.NEWS_FIELD2, b.NEWS_FIELD3, c.CAT_SEO_URL }) .Distinct().OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER).ToList();
            if (getallList.Count > 0)
            {
                for (int i = 0; i < limit; i++)
                {

                    int pos = rdom.Next(1, getallList.Count - 1);
                    if (!lpos.Contains(pos))
                    {
                        lpos.Add(pos);
                        Pro_details_entity pro = new Pro_details_entity();
                        pro.NEWS_ID = getallList[pos].NEWS_ID;
                        pro.NEWS_TITLE = getallList[pos].NEWS_TITLE;
                        pro.NEWS_IMAGE3 = getallList[pos].NEWS_IMAGE3;
                        pro.NEWS_DESC = getallList[pos].NEWS_DESC;
                        pro.NEWS_SEO_URL = getallList[pos].NEWS_SEO_URL;
                        pro.NEWS_URL = getallList[pos].NEWS_URL;
                        pro.CAT_SEO_URL = getallList[pos].CAT_SEO_URL;
                        pro.NEWS_ORDER = Utils.CIntDef(getallList[pos].NEWS_ORDER);
                        pro.NEWS_ORDER_PERIOD = Utils.CIntDef(getallList[pos].NEWS_ORDER_PERIOD);
                        pro.NEWS_PUBLISHDATE = Utils.CDateDef(getallList[pos].NEWS_PUBLISHDATE, DateTime.Now);
                        pro.NEWS_PRICE1 = Utils.CDecDef(getallList[pos].NEWS_PRICE1);
                        pro.NEWS_PRICE2 = Utils.CDecDef(getallList[pos].NEWS_PRICE2);

                        l.Add(pro);
                    }

                }
            }
            return l;
        }
Beispiel #29
0
        /// <summary> 对引用的前置单据的状态进行更新的方法
        /// </summary>
        /// <param name="list_order"></param>
        void ImportPurchasePlanStatus(List<OrderImportStatus> list_order, List<OrderFinishInfo> list_orderinfo)
        {
            SysSQLString sysStringSql = new SysSQLString();
            sysStringSql.cmdType = CommandType.Text;
            List<SysSQLString> listSql = new List<SysSQLString>();
            Dictionary<string, string> dic = new Dictionary<string, string>();
            List<string> list_plan = new List<string>();
            string plan_ids = string.Empty;

            #region 更新前置单据的导入状态字段
            foreach (OrderImportStatus item in list_order)
            {
                if (item.importtype == "采购计划单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_purchase_plan set import_status=@import_status where order_num=@order_num;";
                    dic.Add("import_status", !item.isfinish ? "2" : "3");//单据导入状态,0正常,1占用,2锁定(部分导入), 3锁定(全部导入)
                    dic.Add("order_num", item.order_num);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
                else if (item.importtype == "销售订单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_sale_order set is_occupy=@is_occupy where order_num=@order_num;";
                    dic.Add("is_occupy", !item.isfinish ? "2" : "3");//单据导入状态,0正常,1占用,2锁定(部分导入), 3锁定(全部导入)
                    dic.Add("order_num", item.order_num);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
            } 
            #endregion
            
            #region 更新前置单据中的各个配件的已完成数量
            foreach (OrderFinishInfo item in list_orderinfo)
            {
                if (!list_plan.Contains(item.plan_id))
                {
                    list_plan.Add(item.plan_id);
                    plan_ids = plan_ids + "'" + item.plan_id + "',";
                }
                if (item.importtype == "采购计划单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_purchase_plan_p set finish_counts=@finish_counts where plan_id=@plan_id and parts_code=@parts_code;";
                    dic.Add("finish_counts", item.finish_num);
                    dic.Add("plan_id", item.plan_id);
                    dic.Add("parts_code", item.parts_code);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
                else if (item.importtype == "销售订单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_sale_order_p set finish_count=@finish_count where sale_order_id=@sale_order_id and parts_code=@parts_code;";
                    dic.Add("finish_count", item.finish_num);
                    dic.Add("sale_order_id", item.plan_id);
                    dic.Add("parts_code", item.parts_code);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
            } 
            #endregion
            bool ret = DBHelper.BatchExeSQLStringMultiByTrans("提交宇通采购订单,更新引用的采购计划单或销售订单的导入状态", listSql);
            if (ret)
            {
                if (list_orderinfo.Count > 0)
                {
                    listSql.Clear();
                    plan_ids = plan_ids.Trim(',');
                    string TableName = string.Format(@"
                   (
                    select plan_id,sum(finish_counts) finish_counts,
                    sum(finish_counts*business_price) as finish_money 
                        from tb_parts_purchase_plan_p 
                    where plan_id in ({0})
                    group by plan_id
                    ) tb_purchase_finish", plan_ids);
                    DataTable dt = DBHelper.GetTable("查询采购计划单各配件完成数量和完成金额", TableName, "*", "", "", "");
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sysStringSql = new SysSQLString();
                            sysStringSql.cmdType = CommandType.Text;
                            dic = new Dictionary<string, string>();
                            string sql1 = "update tb_parts_purchase_plan set finish_counts=@finish_counts,plan_finish_money=@plan_finish_money where plan_id=@plan_id;";
                            dic.Add("finish_counts", dt.Rows[i]["finish_counts"].ToString());
                            dic.Add("plan_finish_money", dt.Rows[i]["finish_money"].ToString());
                            dic.Add("plan_id", dt.Rows[i]["plan_id"].ToString());
                            sysStringSql.sqlString = sql1;
                            sysStringSql.Param = dic;
                            listSql.Add(sysStringSql);
                        }
                        DBHelper.BatchExeSQLStringMultiByTrans("完成宇通采购订单后,更新采购计划单的完成数量和完成金额", listSql);
                    }
                }
            }
        }
Beispiel #30
0
        /// <summary>
        /// 每次保养后再多7000公里,或5个月后
        /// </summary>
        /// <param name="organID"></param>
        /// <returns></returns>
        public int AlertMaintenance(int organID)
        {
            List<string> list = new List<string>();

            string sql1 = "select FrameNO,max(Kilometre) as Count,min(MaintenanceDate) as MT from Maintenance where organID = @OrganID group by FrameNO";
            string sql2 = "select FrameNO,max(KM_Count) as Count from Kilometre where organID = @OrganID group by FrameNO";
            SqlParameter[] parameters = {
                    new SqlParameter("@OrganID",organID)
                    };

            DataTable re1 = DbHelperSQL.Query(sql1, parameters).Tables[0];
            DataTable re2 = DbHelperSQL.Query(sql2, parameters).Tables[0];

            DataColumn[] keys = new DataColumn[1];
            keys[0] = re2.Columns["FrameNO"];
            re2.PrimaryKey = keys;

            if (re1 != null || re1.Rows.Count > 0)
            {
                foreach (DataRow dr in re1.Rows)
                {
                    DataRow r = re2.Rows.Find(dr["FrameNO"].ToString());
                    if (r != null)
                    {
                        int x = int.Parse(r["Count"].ToString()) - int.Parse(dr["Count"].ToString());
                        if (x >= 7000)
                        {
                            list.Add(dr["FrameNO"].ToString());
                        }
                    }

                    DateTime mt = DateTime.Parse(dr["MT"].ToString());
                    if (mt.AddMonths(5) < DateTime.Now && !list.Contains(dr["FrameNO"].ToString()))
                    {
                        list.Add(dr["FrameNO"].ToString());
                    }
                }
            }
            return list.Count;
        }