Ejemplo n.º 1
0
        public DataTable dtTrnasfer(DataTable dtTransferSaleCert)
        {
            DataTable dtSearTable = new DataTable();

            dtSearTable           = dtTransferSaleCert;
            dtSearTable.TableName = "Search";
            DataTable dtTarget = new DataTable();

            dtTarget           = dtSearchTable(dtTransferSaleCert);
            dtTarget.TableName = "Target";
            int       qty         = 0;
            string    certificate = "";
            DataTable dtTrnasfer  = opendMFDAO.getTableTransfer();
            DataRow   drTransfer;
            // string SL_NO = "";
            ArrayList rowIndex = new ArrayList();
            bool      flag     = false;

            //int looper = 0;

            for (int loop = 0; loop < dtTarget.Rows.Count; loop++)
            {
                for (int looper = 0; looper < dtSearTable.Rows.Count; looper++)
                {
                    if (dtTarget.Rows[loop]["SALE_NO"].ToString().ToUpper() == dtSearTable.Rows[looper]["SL_NO"].ToString().ToUpper())
                    {
                        if (certificate == "")
                        {
                            certificate = dtSearTable.Rows[looper]["CERTIFICATE"].ToString();
                        }
                        else
                        {
                            certificate = certificate + "," + dtSearTable.Rows[looper]["CERTIFICATE"].ToString();
                        }
                        qty = qty + Convert.ToInt32(dtSearTable.Rows[looper]["QTY"].ToString());
                        rowIndex.Add(looper);
                        flag = true;
                    }
                }

                if (flag)
                {
                    drTransfer                = dtTrnasfer.NewRow();
                    drTransfer["QTY"]         = qty;
                    drTransfer["SL_NO"]       = dtTarget.Rows[loop]["SALE_NO"].ToString().ToUpper();
                    drTransfer["CERTIFICATE"] = certificate.ToString();
                    dtTrnasfer.Rows.Add(drTransfer);
                    dtSearTable           = opendMFDAO.dtRemoveRow(dtSearTable, rowIndex);
                    dtSearTable.TableName = "Search";
                    rowIndex.Clear();
                    qty         = 0;
                    certificate = "";
                    flag        = false;
                }
                if (dtSearTable.Rows.Count == 0)
                {
                    break;
                }
            }

            return(dtTrnasfer);
        }