/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lnkFailedArticles_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (faildArticlesList.ToList().Count > 0)
                {
                    DataTable dtExport = CommonFunc.ConvertListToDataTable(faildArticlesList.ToList());

                    dtExport.Columns[0].ColumnName = "Article Code";
                    dtExport.Columns[1].ColumnName = "Quantity";


                    Cursor.Current = Cursors.WaitCursor;
                    DialogResult resultShow = fbd.ShowDialog();
                    if (resultShow == DialogResult.OK)
                    {
                        string path       = Path.Combine(fbd.SelectedPath, "FailedArticel" + DateTime.Now.ToString("dd-MM-yyyy-hhmm") + ".xls").ToString();
                        bool   IsExported = ConvertListToExcel.DatatableToExcel(dtExport, path);
                        System.Diagnostics.Process.Start(path);
                        if (IsExported)
                        {
                            MessageBox.Show("Exported Successfully");
                        }
                    }
                    Cursor.Current = Cursors.Default;
                }
                else
                {
                    CommonFunc.ShowMessage("Failed Articles does not exist", MessageType.Information);
                }
            }


            catch (Exception ex)
            {
                Logger.Log(ex, Logger.LogingLevel.Error);
                throw ex;
            }
        }
Пример #2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                ArticleManager         articleHierarchyManager = new ArticleManager();
                ArticleDataExportModel articleDataExportModel  = articleHierarchyManager.GetArticlesForBarcodeExportData(NodeCode, CommonModel.SiteCode);
                if (cboBarCodeType.SelectedValue != null)
                {
                    // articleDataExportModel.ArticleDetails = articleDataExportModel.ArticleDetails.Where(x => x.DISCRIPTION == cboBarCodeType.SelectedValue.ToString()).ToList();
                    articleDataExportModel.ArticleDetails = articleDataExportModel.ArticleDetails.Where(x => x.BarcodeType == cboBarCodeType.SelectedValue.ToString()).ToList();  //vipin
                }
                var barCodeList = (from result in articleDataExportModel.ArticleDetails
                                   select new BarcodeModelExcel
                {
                    ArticleName = result.ArticleName,
                    ArticleCode = result.ArticleCode,
                    // BARCODE = result.EAN,
                    BARCODE = result.Barcode,                     // added by vipin
                    SellingPrice = result.SellingPrice,
                    MRP = result.MRP,
                    UOM = result.BaseUoM,
                    NetWeight = result.NetWeight,
                    ExpiryDate = ""
                }).ToList();
                DataTable dtExport = CommonFunc.ConvertListToDataTable(barCodeList);

                dtExport.Columns[0].ColumnName = "Article Name";
                dtExport.Columns[1].ColumnName = "Article Code";
                dtExport.Columns[2].ColumnName = "BARCODE";
                dtExport.Columns[3].ColumnName = "Selling Price";
                dtExport.Columns[4].ColumnName = "MRP";
                dtExport.Columns[5].ColumnName = "UOM";
                dtExport.Columns[6].ColumnName = "Net Weight";
                dtExport.Columns[7].ColumnName = "Expiry Date";
                dtExport.Columns.Add("IsExclude");

                var deleteArticleCodeRow = new List <ItemExclude>();
                for (int i = 1; i < gridBarcode.Rows.Count - 1; i++)
                {
                    ItemExclude itemExclude = new ItemExclude();
                    if (gridBarcode.Rows[i][(int)enumBarcode.Exclude].ToString().ToLower() == "true")
                    {
                        itemExclude.ArticleCode = gridBarcode.Rows[i][(int)enumBarcode.ItemCode].ToString();
                        deleteArticleCodeRow.Add(itemExclude);
                    }
                }


                foreach (DataRow dr in dtExport.Rows)
                {
                    foreach (var item in deleteArticleCodeRow)
                    {
                        if (dr["Article Code"].ToString() == item.ArticleCode)
                        {
                            dr["IsExclude"] = "Exclude";
                            break;
                        }
                        else
                        {
                            dr["IsExclude"] = "Include";
                        }
                    }
                }
                DataView dv = new DataView(dtExport);
                dv.RowFilter = "IsExclude = 'Include'";
                DataTable dt = new DataTable();
                dt = dv.ToTable();
                dt.Columns.Remove("IsExclude");
                Cursor.Current = Cursors.WaitCursor;
                DialogResult resultShow = fbd.ShowDialog();
                if (resultShow == DialogResult.OK)
                {
                    string path       = Path.Combine(fbd.SelectedPath, "ArticelHierarchy" + DateTime.Now.ToString("dd-MM-yyyy-hhmm") + ".xls").ToString();
                    bool   IsExported = ConvertListToExcel.DatatableToExcel(dt, path);
                    System.Diagnostics.Process.Start(path);
                    if (IsExported)
                    {
                        MessageBox.Show("Exported Successfully");
                    }
                }
                Cursor.Current = Cursors.Default;
            }
            catch (System.Exception ex)
            {
                CommonFunc.ShowMessage(ex.Message, MessageType.Information);
                Logger.Log(ex.Message, Logger.LogingLevel.Error);
            }
        }