/// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lnkArtilceExcel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         string appPath = Path.Combine(Application.StartupPath, "Resources\\ArticleDemo.xlsx");
         //Code is added by irfan for Mantis issue on 09/02/2018===============================
         C1XLBook book = new C1XLBook();
         book.Load(appPath);
         XLSheetCollection sheets       = book.Sheets;
         XLSheet           articleSheet = sheets[0];
         if (articleSheet.Rows.Count > 0)
         {
             if (articleSheet.Rows.Count != 1)
             {
                 for (int i = 1; i <= articleSheet.Rows.Count; i++)
                 {
                     i = 1;
                     articleSheet.Rows.RemoveAt(i);
                 }
                 book.Save(appPath);
             }
         }
         //========================================================================================
         System.Diagnostics.Process.Start(appPath);
     }
     catch (Exception ex)
     {
         CommonFunc.ShowMessage(ex.Message, MessageType.Information);
         Logger.Log(ex.Message, Logger.LogingLevel.Error);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUploadArticle_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtArticleFilePath.Text == "")
                {
                    CommonFunc.ShowMessage("Please Browse File", MessageType.Information);
                    return;
                }
                else
                {
                    faildArticlesList = new List <FailedArticleModel>();
                    C1XLBook book = new C1XLBook();
                    book.Load(Path.GetFullPath(txtArticleFilePath.Text));
                    XLSheetCollection sheets = book.Sheets;

                    XLSheet articleSheet = sheets[0];
                    var     articleCodes = new List <string>();
                    var     quantity     = new Dictionary <string, string>();
                    var     totalColumns = articleSheet.Columns.Count;
                    if (totalColumns != 2)
                    {
                        CommonFunc.ShowMessage("Please Browse Proper Format File", MessageType.Information);
                        //  txtArticleFilePath.Text = "";
                        return;
                    }
                    else if (totalColumns == 2)
                    {
                        if (articleSheet[0, 0].Value.ToString() == "ArticleCode" && articleSheet[0, 1].Value.ToString() == "Qty")
                        {
                        }
                        else
                        {
                            CommonFunc.ShowMessage("Please Browse Proper Format File", MessageType.Information);
                            //   txtArticleFilePath.Text = "";
                            return;
                        }
                    }
                    if (articleSheet.Rows.Count > 1)
                    {
                        for (int rowIndex = 1; rowIndex < articleSheet.Rows.Count; rowIndex++)
                        {
                            var   checkQty = articleSheet[rowIndex, 1].Value;
                            Regex patt     = new Regex("^[0-9.]+$");

                            if (articleSheet[rowIndex, 1].Value != null)
                            {
                                if (patt.IsMatch(articleSheet[rowIndex, 1].Value.ToString()) == false)
                                {
                                }
                                else
                                {
                                    articleCodes.Add(articleSheet[rowIndex, 0].Value.ToString());
                                    quantity.Add(articleSheet[rowIndex, 0].Value.ToString(), articleSheet[rowIndex, 1].Value.ToString());
                                    FailedArticleModel faildArticles = new FailedArticleModel();
                                    faildArticles.ArticleCode = articleSheet[rowIndex, 0].Value.ToString();
                                    faildArticles.Quantity    = articleSheet[rowIndex, 1].Value.ToString();
                                    faildArticlesList.Add(faildArticles);
                                }
                            }
                        }
                    }
                    else
                    {
                        CommonFunc.ShowMessage("Please Browse Proper Format File", MessageType.Information);
                        // txtArticleFilePath.Text = "";
                        return;
                    }
                    var selectedArticles = this.articleManager.GetArticlePurchaseList(string.Empty, articleCodes);
                    if (selectedArticles.Count > 0)
                    {
                        for (int rowIndex = 0; rowIndex < selectedArticles.Count; rowIndex++)
                        {
                            var article = selectedArticles.ElementAt(rowIndex);

                            article.Quantity  = decimal.Parse(quantity.Where(a => a.Key == article.ArticleCode).FirstOrDefault().Value);
                            article.NetAmount = article.Quantity * article.Cost.Value;
                            var itemToRemove = faildArticlesList.Single(r => r.ArticleCode == article.ArticleCode);
                            faildArticlesList.Remove(itemToRemove);
                        }
                        AddSelectedArticlesIntoGrid(selectedArticles);
                    }
                    else
                    {
                        CommonFunc.ShowMessage("Articles does not exist.", MessageType.Information);
                    }
                    //  txtArticleFilePath.Text = "";
                }
            }
            catch (Exception ex)
            {
                CommonFunc.ShowMessage(ex.Message, MessageType.Information);
                Logger.Log(ex.Message, Logger.LogingLevel.Error);
            }
        }