Esempio n. 1
0
        private static void AddNodeDataToDataTable(System.Data.DataTable dt, System.Data.DataTable datasource, DataRow node, List<string> listColID, ref int i, int j)
        {
            DataRow newRow = dt.NewRow();
            DataRow[] dv = datasource.Select("ParentID='" + node["ID"] + "'");
            foreach (string colID in listColID)
            {

                //分类名,第二层及以后在前面加空格
                if (colID == "Title" && dv.Length>0)
                {
                    newRow[colID] = "  " + node[colID];
                }
                else if (colID == "ParentID" && dv.Length>0)
                {
                    newRow[colID] = j;
                }
                else
                {
                    newRow[colID] = node[colID];
                }
            }

            ////根分类结束后加空行

            //if (node.ParentNode == null && dt.Rows.Count > 0)
            //{
            //    dt.Rows.Add(new object[] { });
            //}

            dt.Rows.Add(newRow);
            j = i;
            i--;
            dv = datasource.Select("ID='" + node["ParentID"] + "'");
            foreach (DataRow nd in dv)
            {

                AddNodeDataToDataTable(dt,datasource, nd, listColID, ref  i, j);
                // i++;
            }
        }
        static public bool CopyDt(System.Data.DataTable dtFrom, System.Data.DataTable dtTo, List<IntStr> lstIS )
        {
            foreach ( DataRow drFrom in dtFrom.Rows )
            {
                DataRow drTo = dtTo.NewRow();

                bool bValid = false;
                foreach ( IntStr IS in lstIS )
                {
                    if ( !String.IsNullOrEmpty( IS.strVal.Trim() ) && !String.IsNullOrEmpty(drFrom[ IS.nNo ].ToString().Trim() ) )
                    {
                        drTo[IS.strVal] = drFrom[IS.nNo];
                        bValid = true;
                    }
                }

                if ( bValid )
                    dtTo.Rows.Add(drTo);
            }

            return true;
        }
Esempio n. 3
0
        //将内存中数据表格插入到Excel指定工作表的指定位置 为在使用模板时控制格式时使用一
        public void ReadTable(System.Data.DataTable dt, string ws, int startX, int startY)
        {
            int i=0;
            while(true)
            {

                string DataValue = ((Range)GetSheet(ws).Cells[startX + i, 4]).Text.ToString();

                if (DataValue == "") //如果电位值为空,则退出循环
                    break;
                DataRow row = dt.NewRow();
                for (int j = 0; j <= dt.Columns.Count - 1; j++)
                {
                    row[j] = ((Range)GetSheet(ws).Cells[startX + i, j + startY]).Text.ToString();
                    //GetSheet(ws).Cells[startX + i, j + startY] = dt.Rows[i][j].ToString();

                }
                dt.Rows.Add(row);
                i++;
            }
        }
Esempio n. 4
0
		System.Data.DataRow CreateRow(String Text, String Value, System.Data.DataTable dt)
		{

			// Create a DataRow using the DataTable defined in the 
			// CreateDataSource method.
			System.Data.DataRow dr = dt.NewRow();
 
			// This DataRow contains the ColorTextField and ColorValueField 
			// fields, as defined in the CreateDataSource method. Set the 
			// fields with the appropriate value. Remember that column 0 
			// is defined as ColorTextField, and column 1 is defined as 
			// ColorValueField.
			dr[0] = Text;
			dr[1] = Value;
 
			return dr;

		}
Esempio n. 5
0
        /// <summary>
        /// 분개 라인정보를 생성합니다.
        /// </summary>
        /// <param name="dt_JELines"></param>
        /// <param name="U_SHORTNM">ShortName</param>
        /// <param name="U_ACCTCD">AccountCode</param>
        /// <param name="U_PRCCD">ProfitCode</param>
        /// <param name="U_LINEMEMO">LineMemo</param>
        /// <param name="U_INAMT"></param>
        /// <param name="U_OUTAMT"></param>
        private void SetJournalEntries_Line(ref System.Data.DataTable dt_JELines, string U_GLACTCD, string U_SHORTNM, string U_ACCTCD, string U_PRCCD, string JEOKYO, string U_LINEMEMO, double U_INAMT, double U_OUTAMT)
        {

            string edtACCTCD = oForm.DataSources.UserDataSources.Item("edtACCTCD").Value;//출금계좌계정

            string U_OCRCD1 = U_PRCCD;
            string U_OCRCD2 = string.Empty;
            string U_OCRCD3 = string.Empty;
            string U_OCRCD4 = string.Empty;
            string U_OCRCD5 = string.Empty;

            try
            {
                System.Data.DataRow dr_JELine = null;

                if (U_INAMT >0)
                {
                    //차변
                    dr_JELine = dt_JELines.NewRow();
                    dr_JELine["AccountCode"] = U_GLACTCD;
                    dr_JELine["ShortName"] = U_GLACTCD;
                    dr_JELine["Debit"] = U_INAMT;

                    dr_JELine["CostingCode"] = U_OCRCD1;
                    //dr_JELine["CostingCode2"] = U_OCRCD2;
                    //dr_JELine["CostingCode3"] = U_OCRCD3;
                    //dr_JELine["CostingCode4"] = U_OCRCD4;
                    //dr_JELine["CostingCode5"] = U_OCRCD5;

                    dr_JELine["LineMemo"] = JEOKYO;

                    dt_JELines.Rows.Add(dr_JELine);


                    //대변
                    dr_JELine = dt_JELines.NewRow();
                    dr_JELine["AccountCode"] = U_ACCTCD;
                    dr_JELine["ShortName"] = U_SHORTNM;
                    dr_JELine["Credit"] = U_INAMT;

                    dr_JELine["CostingCode"] = U_OCRCD1;
                    //dr_JELine["CostingCode2"] = U_OCRCD2;
                    //dr_JELine["CostingCode3"] = U_OCRCD3;
                    //dr_JELine["CostingCode4"] = U_OCRCD4;
                    //dr_JELine["CostingCode5"] = U_OCRCD5;

                    dr_JELine["LineMemo"] = U_LINEMEMO;

                    dt_JELines.Rows.Add(dr_JELine);
                }
                if (U_OUTAMT>0)
                {
                    //대변
                    dr_JELine = dt_JELines.NewRow();
                    dr_JELine["AccountCode"] = U_GLACTCD;
                    dr_JELine["ShortName"] = U_GLACTCD;
                    dr_JELine["Credit"] = U_OUTAMT;

                    dr_JELine["CostingCode"] = U_OCRCD1;
                    //dr_JELine["CostingCode2"] = U_OCRCD2;
                    //dr_JELine["CostingCode3"] = U_OCRCD3;
                    //dr_JELine["CostingCode4"] = U_OCRCD4;
                    //dr_JELine["CostingCode5"] = U_OCRCD5;

                    dr_JELine["LineMemo"] = JEOKYO;

                    dt_JELines.Rows.Add(dr_JELine);


                    //차변
                    dr_JELine = dt_JELines.NewRow();
                    dr_JELine["AccountCode"] = U_ACCTCD;
                    dr_JELine["ShortName"] = U_SHORTNM;
                    dr_JELine["Debit"] = U_OUTAMT;

                    dr_JELine["CostingCode"] = U_OCRCD1;
                    //dr_JELine["CostingCode2"] = U_OCRCD2;
                    //dr_JELine["CostingCode3"] = U_OCRCD3;
                    //dr_JELine["CostingCode4"] = U_OCRCD4;
                    //dr_JELine["CostingCode5"] = U_OCRCD5;

                    dr_JELine["LineMemo"] = U_LINEMEMO;

                    dt_JELines.Rows.Add(dr_JELine);
                }

               

            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 6
0
 protected void GenerateRow(System.Data.DataTable dt, List<string> s)
 {
     DataRow dtrow = dt.NewRow();    // Create New Row
     dtrow["Ref"] = s[0];            //Bind Data to Columns
     dtrow["Part"] = s[1];
     dtrow["Description"] = s[2];
     dtrow["Qty"] = s[3];
     dtrow["AdditionalDetails"] = s[4];
     dt.Rows.Add(dtrow);
     _table = dt;
     gvDetails.DataSource = dt;
     gvDetails.DataBind();
     HttpContext.Current.Session["name"] = dt;
 }
Esempio n. 7
0
        // Name: LoadAirport - populate a dataset with retrieved data
        //
        // Description:
        //      Perform a call to a row producing procedure to populate a data
        //      set with results from the database.
        //
        // Inputs:
        //      direction       Sets the parameters according to direction.
        //      area
        //      airportDataSet
        //
        // Outputs:
        //      airpotDataSet
        //
        // Returns:
        //      None.
        //
        // History:
        //      02-Oct-2006 ([email protected])
        //          Created.
        //      13-Oct-2006 ([email protected])
        //          Add start row to the result set.
        public void LoadAirport(int direction, String area, System.Data.DataTable airportTable)
        {
            DataRow dataRow;

            IngresParameter country = new Ingres.Client.IngresParameter(
                "ap_ccode", IngresType.NChar);
            IngresParameter region = new Ingres.Client.IngresParameter(
                "ap_place", IngresType.NVarChar);
            region.Value = area;
            airportTable.Clear();
            dataRow = airportTable.NewRow();
            dataRow["ap_iatacode"] = rm.GetString("StartAirportCode"); ;
            airportTable.Rows.InsertAt(dataRow, 0);

            try
            {
                ingresDataAdapter3.SelectCommand.Connection.Open();
                ingresDataAdapter3.SelectCommand.Prepare();
                ingresDataAdapter3.SelectCommand.Parameters.Clear();
                switch (direction)
                {
                    case DEPART:
                        country.Value = departing.country;
                        departing.region = region.Value.ToString();
                        break;
                    case ARRIVE:
                        country.Value = arriving.country;
                        arriving.region = region.Value.ToString();
                        break;
                }
                ingresDataAdapter3.SelectCommand.Parameters.Add(country);
                ingresDataAdapter3.SelectCommand.Parameters.Add(region);
                ingresDataAdapter3.Fill(airportTable);
            }
            finally
            {
                if (ingresDataAdapter3 != null &&
                    ingresDataAdapter3.SelectCommand != null &&
                    ingresDataAdapter3.SelectCommand.Connection != null)
                    ingresDataAdapter3.SelectCommand.Connection.Close();
            }
        }
Esempio n. 8
0
 private void AddNodeDataToDataTable(System.Data.DataTable dt, System.Data.DataTable datasource, DataRow node, List<string> listColID, bool bRemove)
 {
     DataRow newRow = dt.NewRow();
     DataRow[] dv = datasource.Select("ID='" + node["ParentID"] + "'");
     foreach (string colID in listColID)
     {
         //分类名,第二层及以后在前面加空格
         if (colID == "Title" && dv.Length > 0)
         {
             newRow[colID] = "  " + node[colID];
         }
         else
         {
             newRow[colID] = node[colID];
         }
     }
     if (bRemove)
     {
         if (newRow["Col1"].ToString() != "1" && newRow["BuildEd"].ToString() != "total")
             dt.Rows.Add(newRow);
     }
     else
         dt.Rows.Add(newRow);
     dv = datasource.Select("ParentID='" + node["ID"] + "'");
     foreach (DataRow nd in dv)
     {
         AddNodeDataToDataTable(dt, datasource, nd, listColID, bRemove);
     }
 }
Esempio n. 9
0
 private static void PintarArbolPadre(CategoriaDTO obj, List<CategoriaDTO> lstCatMontos, EmpresaDTO objEmpresa, System.Data.DataTable dt)
 {
     System.Data.DataRow row = dt.NewRow();
     row["Nivel"] = obj.Nivel;
     row["Partida de Presupuesto"] = obj.Nombre;
     Decimal pMonto = lstCatMontos.SingleOrDefault(x => x.IdCategoria == obj.IdCategoria).Presupuesto.GetValueOrDefault();
     row["MONTO SIN IGV"] = pMonto.ToString("N2", CultureInfo.InvariantCulture);
     row["PRESUPUESTO SIN IGV"] = obj.Presupuesto.GetValueOrDefault().ToString("N2", CultureInfo.InvariantCulture);
     Decimal porcentaje = obj.Presupuesto.GetValueOrDefault() != 0 ? pMonto / obj.Presupuesto.GetValueOrDefault() : 0;
     row["EJECUCION DEL PRESUPUESTO"] = Math.Abs(porcentaje).ToString("P2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row);
     foreach (var hijo in obj.Hijos)
     {
         PintarArbolPadre(hijo, lstCatMontos, objEmpresa, dt);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 파일 업로드용 DataTable에 자료 입력
        /// </summary>
        /// <param name="LayOutDataTable"></param>
        /// <param name="targetDataTable"></param>
        /// <param name="upRowText"></param>
        /// <param name="dataType"></param>
        public void SetDataTable(System.Data.DataTable LayOutDataTable, ref System.Data.DataTable targetDataTable, string upRowText, string dataType)
        {
            if (LayOutDataTable != null)
            {
                System.Data.DataRow[] foundRows = LayOutDataTable.Select(string.Format("U_RMK1 = '{0}'", dataType));

                string columnName = string.Empty;

                int start = -1;
                int len = -1;

                DataRow tempdr = targetDataTable.NewRow();

                foreach (DataRow dr in foundRows)
                {
                    columnName = dr["U_CD"].ToString();

                    start = int.Parse(dr["U_RMK2"].ToString());
                    len = int.Parse(dr["U_RMK4"].ToString());

                    if (upRowText.Trim().Length < start)
                        break;

                    //tempdr[columnName] = upRowText.Substring(start - 1, len).Trim();
                    tempdr[columnName] = SO_COMMON_HRD.GetWordByByte(upRowText, start - 1, len).Trim();
                }

                targetDataTable.Rows.Add(tempdr);
            }

        }
        public string ReadToDataTable(System.Data.DataTable dtExcel, string colPrefix, int startRow, string indicatorColName, string endText)
        {
            try
            {

                Dictionary<string, string> names = GetNamedRanges();

                for (int row = startRow; ; row++)
                {
                    string colText = GetCellValue(row, indicatorColName);
                    if (colText == endText) break;

                    DataRow dr = dtExcel.NewRow();
                    foreach (DataColumn dc in dtExcel.Columns)
                    {
                        string fldName = colPrefix + dc.ColumnName;
                        fldName = fldName.ToLower();
                        if (names.ContainsKey(fldName))
                        {
                            object v = GetCellValue(row, fldName);
                            if (v == null || v.ToString() == "")
                            {
                                dr[dc.ColumnName] = DBNull.Value;
                            }
                            else
                            {
                                dr[dc.ColumnName] = GetCellValue(row, fldName);
                            }
                        }
                    }
                    dtExcel.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "";
        }
        public string ReadToDataTable(ref System.Data.DataTable dtWrksht, string wrkshtName, int maxRow, int maxCol)
        {
            try
            {
                if (!FindWorksheet(wrkshtName)) throw new Exception("Unable to find the worksheet '" + wrkshtName + "'.");

				if (maxRow == 0) maxRow = int.MaxValue;
				if (maxCol == 0) maxCol = int.MaxValue;
                for (int row = 1; row <= maxRow; row++)
                {
                    DataRow drNew = dtWrksht.NewRow();

                    for (int col = 1; col <= maxCol; col++)
                    {
                        drNew[col - 1] = GetCellVal(row, col);
                    }

                    dtWrksht.Rows.Add(drNew);
                }
            }
            catch (Exception ex)
            {
                return ("Unable to read the Excel worksheet '" + wrkshtName + "' into a DataTable.\n\n" + ex.Message);
            }

            return "";
        }
Esempio n. 13
0
 private void setgisxml(ref System.Data.DataTable dt,IGroupLayer pGroupLayer)
 {
     ICompositeLayer comLayer = pGroupLayer as ICompositeLayer;
     System.Data.DataRow dr;
     for (int i = 0; i < comLayer.Count; i++)
     {
         ILayer player = comLayer.get_Layer(i);
         if (player is IGroupLayer)
         {
             dr = dt.NewRow();
             dr[0] = "layer";
             dr[1] = player.Name;
             dr[2] = player.Visible.ToString();
             dt.Rows.Add(dr);
             setgisxml(ref dt, player as IGroupLayer);
         }
         else
         {
             dr = dt.NewRow();
             dr[0] = "layer";
             dr[1] = player.Name;
             dr[2] = player.Visible.ToString();
             dt.Rows.Add(dr);
         }
     }
 }
Esempio n. 14
0
        private static void AddRow(System.Data.DataTable DisplayedTable, String TheFirstColumn, string TheSecondColumn)
        {
            System.Data.DataRow NewRow;

            NewRow = DisplayedTable.NewRow();

            NewRow["Параметр"] = TheFirstColumn;
            NewRow["Значение"] = TheSecondColumn;

            DisplayedTable.Rows.Add(NewRow);

            NewRow.Delete();
        }
Esempio n. 15
0
		/// <summary>
		/// 从 XmlNode(树) 加载表
		/// </summary>
		/// <param name="dt">表</param>
		/// <param name="Columns">需要的列名列表</param>
		/// <param name="xn">XmlNode</param>
		public static void LoadTreeXmlNode(System.Data.DataTable dt, string[] Columns,
			XmlNode xn)
		{
			System.Data.DataRow dr = dt.NewRow();
			foreach (string ColName in Columns)
			{
				if (xn.Attributes[ColName] != null)
				{
					dr[ColName] = xn.Attributes[ColName].Value;
				}
			}
			dt.Rows.Add(dr);

			foreach (XmlNode xnc in xn.ChildNodes)
			{
				LoadTreeXmlNode(dt, Columns, xnc);
			}
		}
Esempio n. 16
0
        /// <summary>
        /// Add a column of values to the specified data table
        /// </summary>
        /// <param name="table">The table to add values to</param>
        /// <param name="columnName">The name of the column</param>
        /// <param name="values">The values to add to the table.</param>
        static public void AddColumnOfObjects(System.Data.DataTable table, string columnName, IEnumerable values)
        {
            // Make sure the table has the specified column
            if (!table.Columns.Contains(columnName))
            {
                table.Columns.Add(columnName, values.GetType().GetElementType());
            }

            if (values != null)
            {
                int row = 0;
                foreach (object value in values)
                {
                    // Make sure we have enough rows.
                    if (table.Rows.Count <= row)
                    {
                        table.Rows.Add(table.NewRow());
                    }

                    // Determine if this value should be put into the table.
                    // If the value is a double.NaN then don't put into table.
                    // All other values do get inserted.
                    bool insertValue = true;
                    if (value is double && (double.IsNaN((double) value) || (double) value == MathUtilities.MissingValue))
                    {
                        insertValue = false;
                    }

                    // Set the cell value in table.
                    if (insertValue)
                    {
                        table.Rows[row][columnName] = value;
                    }

                    row++;
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 전표행의 라인정보 DataTable에 를 생성합니다.
        /// </summary>
        /// <param name="dt_JELines"></param>
        /// <param name="U_OCRCD1"></param>
        /// <param name="AccountCode"></param>
        /// <param name="ShortName"></param>
        /// <param name="Debit"></param>
        /// <param name="Credit"></param>
        /// <returns></returns>
        private static System.Data.DataRow SetJournalEntries_Line(ref System.Data.DataTable dt_JELines, string U_OCRCD1, string AccountCode, string ShortName, double Debit, double Credit)
        {
            System.Data.DataRow dr_JELine = null;

            //차변
            dr_JELine = dt_JELines.NewRow();
            dr_JELine["AccountCode"] = AccountCode;
            dr_JELine["ShortName"] = ShortName;
            dr_JELine["Debit"] = Debit;
            dr_JELine["Credit"] = Credit;
            dr_JELine["CostingCode"] = U_OCRCD1;
            //dr_JELine["CostingCode2"] = U_OCRCD2;
            //dr_JELine["CostingCode3"] = U_OCRCD3;
            //dr_JELine["CostingCode4"] = U_OCRCD4;
            //dr_JELine["CostingCode5"] = U_OCRCD5;

            return dr_JELine;
        }
Esempio n. 18
0
        private static void PintarAreas(AreaDTO obj, Decimal SumaTotal, System.Data.DataTable dt)
        {
            System.Data.DataRow row1 = dt.NewRow();
            row1[0] = obj.Nombre;
            row1["Monto con IGV"] = obj.SumaClientes.ToString("N2", CultureInfo.InvariantCulture);
            row1["Monto sin IGV"] = obj.SumaClientes_SinIGV.ToString("N2", CultureInfo.InvariantCulture);
            Decimal porcentaje = SumaTotal == 0 ? 0 : obj.SumaClientes / SumaTotal;
            row1["Porcentaje"] = porcentaje.ToString("P2", CultureInfo.InvariantCulture);
            dt.Rows.Add(row1);

            foreach (var item in obj.lstClientes)
            {
                if (item.Monto != 0)
                {
                    System.Data.DataRow row2 = dt.NewRow();
                    row2[1] = item.Nombre;
                    row2["Monto con IGV"] = item.Monto.ToString("N2", CultureInfo.InvariantCulture);
                    row2["Monto sin IGV"] = item.MontoSinIGV.ToString("N2", CultureInfo.InvariantCulture);
                    dt.Rows.Add(row2);
                }
            }
        }
Esempio n. 19
0
        private void SetJournalEntries_Line(ref System.Data.DataTable dt_JELines,ref System.Data.DataTable dt_KIS_SD0050T_HRD, string U_ITMGRPCD, double U_AMT, double U_VAT, string U_VATCD)
        {

            string U_PUBLICA = dt_KIS_SD0050T_HRD.Rows[0]["U_PUBLICA"].ToString().Trim();//간행물 

            string U_OCRCD1 = dt_KIS_SD0050T_HRD.Rows[0]["U_PRCCD"].ToString().Trim();//코스트센터 : 매출부서
            string U_OCRCD2 = string.Empty;
            string U_OCRCD3 = string.Empty;
            string U_OCRCD4 = string.Empty;
            string U_OCRCD5 = string.Empty;

            string U_CARDCD = dt_KIS_SD0050T_HRD.Rows[0]["U_CARDCD"].ToString().Trim();//매출처



            try
            {

                //계정정의

                SD_COMMON_HRD.GLAccountInfo2 oGLAccountInfo2 = SD_COMMON_HRD.GetGLAccountInfo2(U_PUBLICA);

                //string DebPayAcct = FN.GetRecordsetValue(string.Format("SELECT DebPayAcct FROM [OCRD] WHERE CardCode = '{0}'", U_CARDCD));//관리계정:차변(회계탭>채권계정)예) 외상매출금
                string DebPayAcct = oGLAccountInfo2.U_AC03;//2014.05.08 간행물별로 채권계정으로 변경.
                string VATAccount = FN.GetRecordsetValue(string.Format("SELECT Account FROM [OVTG] WHERE Code = '{0}'", U_VATCD));//부가세 계정코드 가져오기


                if (string.IsNullOrEmpty(oGLAccountInfo2.U_AC01))
                {
                    throw new Exception(string.Format("광고관리에 대한 GL계정이 정의되지 않았습니다. [{0}][매출계정]", U_PUBLICA));
                }
                if (string.IsNullOrEmpty(DebPayAcct))
                {
                    throw new Exception(string.Format("광고관리에 대한 GL계정이 정의되지 않았습니다. [{0}][매출처 채권 계정]", U_PUBLICA));
                }
                if (string.IsNullOrEmpty(VATAccount))
                {
                    throw new Exception(string.Format("부가세 코드에 대한 계정이 정의되지 않았습니다.. [{0}][부가세 계정]", U_VATCD));
                }

                System.Data.DataRow dr_JELine = null;

                //차변
                dr_JELine = dt_JELines.NewRow();
                dr_JELine["AccountCode"] = oGLAccountInfo2.U_AC01;
                dr_JELine["ShortName"] = oGLAccountInfo2.U_AC01;
                dr_JELine["Credit"] = U_AMT;

                dr_JELine["CostingCode"] = U_OCRCD1;
                //dr_JELine["CostingCode2"] = U_OCRCD2;
                //dr_JELine["CostingCode3"] = U_OCRCD3;
                //dr_JELine["CostingCode4"] = U_OCRCD4;
                //dr_JELine["CostingCode5"] = U_OCRCD5;

                dt_JELines.Rows.Add(dr_JELine);

                //차변:부가세 
                if (U_VATCD != "")
                {
                    dr_JELine = dt_JELines.NewRow();
                    dr_JELine["AccountCode"] = VATAccount;
                    dr_JELine["ShortName"] = VATAccount;
                    dr_JELine["Credit"] = U_VAT;
                    dr_JELine["TaxGroup"] = U_VATCD;

                    dr_JELine["CostingCode"] = U_OCRCD1;
                    //dr_JELine["CostingCode2"] = U_OCRCD2;
                    //dr_JELine["CostingCode3"] = U_OCRCD3;
                    //dr_JELine["CostingCode4"] = U_OCRCD4;
                    //dr_JELine["CostingCode5"] = U_OCRCD5;

                    #region 부가세 행 사용자정의 필드
                    if (FN.GetUserFieldValidation("JDT1", "CARDCD"))
                    {
                        dr_JELine["U_CARDCD"] = U_CARDCD;
                    }
                    if (FN.GetUserFieldValidation("JDT1", "CARDNM"))
                    {
                        dr_JELine["U_CARDNM"] = FN.GetRecordsetValue(string.Format("select CardName from ocrd where CardCode = '{0}'", U_CARDCD));
                    }

                    if (FN.GetUserFieldValidation("JDT1", "SAUPNO"))
                    {
                        dr_JELine["U_SAUPNO"] = FN.GetRecordsetValue(string.Format("SELECT (CASE WHEN A.U_RRNYN = 'Y' THEN A.U_RRN ELSE A.VATRegNum END) AS SAUPNO FROM OCRD AS A WHERE A.CARDCODE = '{0}'", U_CARDCD));
                    }
                    if (FN.GetUserFieldValidation("JDT1", "SUPAMT"))
                    {
                        dr_JELine["U_SUPAMT"] = U_AMT;
                    }

                    if (FN.GetUserFieldValidation("JDT1", "VAT"))
                    {
                        dr_JELine["U_VAT"] = U_VAT;
                    }
                    #endregion

                    dt_JELines.Rows.Add(dr_JELine);
                }

                //대변
                dr_JELine = dt_JELines.NewRow();
                dr_JELine["AccountCode"] = DebPayAcct;
                dr_JELine["ShortName"] = U_CARDCD;
                dr_JELine["Debit"] = U_AMT + U_VAT;


                dr_JELine["CostingCode"] = U_OCRCD1;
                //dr_JELine["CostingCode2"] = U_OCRCD2;
                //dr_JELine["CostingCode3"] = U_OCRCD3;
                //dr_JELine["CostingCode4"] = U_OCRCD4;
                //dr_JELine["CostingCode5"] = U_OCRCD5;

                dt_JELines.Rows.Add(dr_JELine);

            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 20
0
 private static void PintarAreasIE(AreaDTO obj, System.Data.DataTable dt)
 {
     DataRow row1 = dt.NewRow();
     row1[0] = obj.Nombre.ToUpper();
     dt.Rows.Add(row1);
     DataRow row2 = dt.NewRow();
     row2[1] = "VENTAS";
     row2[2] = obj.Ingresos.ToString("N2", CultureInfo.InvariantCulture);
     row2[3] = obj.Ingresos_SinIGV.ToString("N2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row2);
     DataRow row3 = dt.NewRow();
     row3[1] = "GASTOS";
     row3[2] = obj.Egresos.ToString("N2", CultureInfo.InvariantCulture);
     row3[3] = obj.Egresos_SinIGV.ToString("N2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row3);
     DataRow row4 = dt.NewRow();
     row4[0] = "NETO";
     row4[2] = (obj.Ingresos + obj.Egresos).ToString("N2", CultureInfo.InvariantCulture);
     row4[3] = (obj.Ingresos_SinIGV + obj.Egresos_SinIGV).ToString("N2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row4);
 }
Esempio n. 21
0
 private System.Data.DataTable BuildTableRows(Google.Apis.Analytics.v3.Data.GaData gaData, System.Data.DataTable table)
 {
     foreach (var ls in gaData.Rows)
     {
         System.Data.DataRow row = table.NewRow();
         for(int i = 0; i < ls.Count(); i++)
         {
             row[i] = ls[i];
         }
         table.Rows.Add(row);
     }
     return table;
 }
Esempio n. 22
0
 private static void PintarGestionPorMesIE(LiquidezDTO obj, System.Data.DataTable dt)
 {
     DataRow row1 = dt.NewRow();
     row1[0] = obj.nombreMes;
     dt.Rows.Add(row1);
     DataRow row2 = dt.NewRow();
     row2[1] = "VENTAS";
     row2[2] = obj.Ingreso.ToString("N2", CultureInfo.InvariantCulture);
     row2[3] = obj.Ingreso_SinIGV.ToString("N2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row2);
     DataRow row3 = dt.NewRow();
     row3[1] = "GASTOS";
     row3[2] = obj.Egreso.ToString("N2", CultureInfo.InvariantCulture);
     row3[3] = obj.Egreso_SinIGV.ToString("N2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row3);
     DataRow row4 = dt.NewRow();
     row4[1] = "NETO";
     row4[2] = (obj.Ingreso + obj.Egreso).ToString("N2", CultureInfo.InvariantCulture);
     row4[3] = (obj.Ingreso_SinIGV + obj.Egreso_SinIGV).ToString("N2", CultureInfo.InvariantCulture);
     dt.Rows.Add(row4);
 }
Esempio n. 23
0
        private static void UpdateHpRow(System.Data.DataRow row, string symbol, ISimulateStrategy[,] strategys, System.Data.DataTable dtDest, bool updateUnComplete)
        {
            DateTime date = (DateTime)row["Date"];
            if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
                return;
            long time = WekaUtils.GetTimeFromDate(date);
            //if (alreadyHps.ContainsKey(time))
            //    return;

            System.Console.WriteLine(string.Format("Now updatehp of {0}, {1}", date.ToString(Parameters.DateTimeFormat), symbol));

            sbyte?[, ,] hps;
            long?[, ,] hpTimes;

            var hpRow = DbHelper.Instance.ExecuteDataRow(string.Format("SELECT * FROM {0}_HP WHERE TIME = {1}", symbol, time));
            if (hpRow != null)
            {
                hps = HpData.DeserializeHp((byte[])hpRow["hp"]);
                hpTimes = HpData.DeserializeHpTimes((byte[])hpRow["hp_date"]);
            }
            else
            {
                hps = new sbyte?[Parameters.AllDealTypes.Length, TestParameters.CandidateParameter4Db.BatchTps.Length, TestParameters.CandidateParameter4Db.BatchSls.Length];
                hpTimes = new long?[Parameters.AllDealTypes.Length, TestParameters.CandidateParameter4Db.BatchTps.Length, TestParameters.CandidateParameter4Db.BatchSls.Length];
                for (int k = 0; k < Parameters.AllDealTypes.Length; ++k)
                {
                    for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
                    {
                        for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                        {
                            hps[k, i, j] = null;
                            hpTimes[k, i, j] = null;
                        }
                    }
                }
            }

            bool[] isComplete = new bool[Parameters.AllDealTypes.Length];
            for (int k = 0; k < Parameters.AllDealTypes.Length; ++k)
            {
                char dealType = Parameters.AllDealTypes[k];
                isComplete[k] = true;

                for (int i = 0; i < TestParameters.CandidateParameter4Db.BatchTps.Length; ++i)
                {
                    if (!isComplete[k])
                        break;
                    for (int j = 0; j < TestParameters.CandidateParameter4Db.BatchSls.Length; ++j)
                    {
                        if (!isComplete[k])
                            break;

                        if (hps[k, i, j].HasValue && hps[k, i, j] != -1)
                            continue;

                        ISimulateStrategy strategy = strategys[i, j];

                        DateTime? closeDate;
                        bool? hp;
                        if (dealType == 'B')
                            hp = strategy.DoBuy(date, (double)row["Close"], out closeDate);
                        else if (dealType == 'S')
                            hp = strategy.DoSell(date, (double)row["Close"], out closeDate);
                        else
                            throw new ArgumentException("Invalid dealtype of " + dealType);

                        if (hp.HasValue)
                        {
                            if (hp.Value)
                            {
                                // tp
                                for (int jj = j; jj < TestParameters.CandidateParameter4Db.BatchSls.Length; ++jj)
                                {
                                    hps[k, i, jj] = 1;
                                    hpTimes[k, i, jj] = WekaUtils.GetTimeFromDate(closeDate.Value);
                                }
                            }
                            else
                            {
                                for (int ii = i; ii < TestParameters.CandidateParameter4Db.BatchTps.Length; ++ii)
                                {
                                    hps[k, ii, j] = 0;
                                    hpTimes[k, ii, j] = WekaUtils.GetTimeFromDate(closeDate.Value);
                                }
                            }
                        }
                        else
                        {
                            isComplete[k] = false;
                            //if (dealType == 'B')
                            //    hp = strategy.DoBuy(date, (double)row["Close"], out closeDate);
                            //else if (dealType == 'S')
                            //    hp = strategy.DoSell(date, (double)row["Close"], out closeDate);

                            //if (!updateUnComplete)
                            //{
                            //    lock (dtDest)
                            //    {
                            //        DbHelper.Instance.BulkCopy(dtDest, string.Format("{0}_HP", symbol));
                            //        dtDest.Rows.Clear();

                            //        throw new AssertException("hp should not be null");
                            //    }
                            //}
                        }
                    }
                }
            }
            if (hpRow != null)
            {
                System.Data.SqlClient.SqlCommand updateCmd = new SqlCommand(string.Format("UPDATE [{0}_HP] SET [hp] = @hp,[hp_date] = @hp_date,[IsComplete] = @IsComplete WHERE [Time] = @Time", symbol));
                updateCmd.Parameters.AddWithValue("@hp", HpData.SerializeHp(hps));
                updateCmd.Parameters.AddWithValue("@hp_date", HpData.SerializeHpTimes(hpTimes));
                updateCmd.Parameters.AddWithValue("@IsComplete", WekaUtils.AndAll(isComplete));
                updateCmd.Parameters.AddWithValue("@Time", time);

                Feng.Data.DbHelper.Instance.ExecuteNonQuery(updateCmd);
            }
            else
            {
                lock (dtDest)
                {
                    if (!updateUnComplete && (!isComplete[0] || !isComplete[1]))
                        return;

                    System.Data.DataRow row2 = dtDest.NewRow();
                    row2["Time"] = row["Time"];
                    row2["hp"] = HpData.SerializeHp(hps);
                    row2["hp_date"] = HpData.SerializeHpTimes(hpTimes);
                    row2["IsComplete"] = WekaUtils.AndAll(isComplete);
                    dtDest.Rows.Add(row2);

                    if (dtDest.Rows.Count >= 100)
                    {
                        DbHelper.Instance.BulkCopy(dtDest, string.Format("{0}_HP", symbol));
                        dtDest.Rows.Clear();
                    }
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 분개 행을 처리하기 위한 DataTable값을 정의합니다.
        /// </summary>
        /// <param name="dt_JELines">분개 행 데이터 테이블</param>
        /// <param name="U_PUBLICA">간행물</param>
        /// <param name="U_PRCCD_Line">코스트센터:행</param>
        /// <param name="U_AMTBP">대행사 금액</param>
        /// <param name="U_VAT">대행사 부가세</param>
        /// <param name="U_VATCD">대행사 세금코드</param>
        private void SetJournalEntries_Line(ref System.Data.DataTable dt_JELines, string U_PUBLICA,string U_PRCCD_Line, double U_AMTBP, double U_VAT, string U_VATCD)
        {

            SAPbouiCOM.DBDataSource oKIS_SD0070T_HRD = oForm.DataSources.DBDataSources.Item("@KIS_SD0070T_HRD");

            string U_PRCCD = oKIS_SD0070T_HRD.GetValue("U_PRCCD", 0).Trim();//코스트센터 : 담당부서(매입);

            string U_OCRCD1 = U_PRCCD_Line;
            string U_OCRCD2 = string.Empty;
            string U_OCRCD3 = string.Empty;
            string U_OCRCD4 = string.Empty;
            string U_OCRCD5 = string.Empty;

            string U_BPCD = oKIS_SD0070T_HRD.GetValue("U_BPCD", 0).Trim(); ;//대행사
            string U_ACCTCD = oKIS_SD0070T_HRD.GetValue("U_ACCTCD", 0).Trim(); ;////관리계정:차변(회계탭>채권계정)

            try
            {
                //계정정의
                SD_COMMON_HRD.GLAccountInfo2 oGLAccountInfo2 = SD_COMMON_HRD.GetGLAccountInfo2(U_PUBLICA);

                //string DebPayAcct = FN.GetRecordsetValue(string.Format("SELECT DebPayAcct FROM [OCRD] WHERE CardCode = '{0}'", U_BPCD));//관리계정:차변(회계탭>채권계정)예) 외상매입금
                string VATAccount = FN.GetRecordsetValue(string.Format("SELECT Account FROM [OVTG] WHERE Code = '{0}'", U_VATCD));//부가세 계정코드 가져오기

                if (oGLAccountInfo2.U_AC02 == "")
                {
                    throw new Exception(string.Format("광고관리에 대한 대행수수료계정이 정의되지 않았습니다. [{0}][대행수수료계정]", U_PUBLICA));
                }

                System.Data.DataRow dr_JELine = null;

                //차변
                dr_JELine = dt_JELines.NewRow();
                dr_JELine["AccountCode"] = oGLAccountInfo2.U_AC02;
                dr_JELine["ShortName"] = oGLAccountInfo2.U_AC02;
                dr_JELine["Debit"] = U_AMTBP;

                dr_JELine["CostingCode"] = U_OCRCD1;
                //dr_JELine["CostingCode2"] = U_OCRCD2;
                //dr_JELine["CostingCode3"] = U_OCRCD3;
                //dr_JELine["CostingCode4"] = U_OCRCD4;
                //dr_JELine["CostingCode5"] = U_OCRCD5;

                dt_JELines.Rows.Add(dr_JELine);

                //차변:부가세 
                //2014-07-29 허향행 부가세는 문서(헤더)의 코스트센터로 처리합니다.
                if (U_VATCD != "")
                {
                    dr_JELine = dt_JELines.NewRow();
                    dr_JELine["AccountCode"] = VATAccount;
                    dr_JELine["ShortName"] = VATAccount;
                    dr_JELine["Debit"] = U_VAT;
                    dr_JELine["TaxGroup"] = U_VATCD;

                    dr_JELine["CostingCode"] = U_PRCCD;// U_OCRCD1;
                    //dr_JELine["CostingCode2"] = U_OCRCD2;
                    //dr_JELine["CostingCode3"] = U_OCRCD3;
                    //dr_JELine["CostingCode4"] = U_OCRCD4;
                    //dr_JELine["CostingCode5"] = U_OCRCD5;

                    #region 부가세 행 사용자정의 필드
                    if (FN.GetUserFieldValidation("JDT1", "CARDCD"))
                    {
                        dr_JELine["U_CARDCD"] = U_BPCD;
                    }
                    if (FN.GetUserFieldValidation("JDT1", "CARDNM"))
                    {
                        dr_JELine["U_CARDNM"] = FN.GetRecordsetValue(string.Format("select CardName from ocrd where CardCode = '{0}'", U_BPCD));
                    }

                    if (FN.GetUserFieldValidation("JDT1", "SAUPNO"))
                    {
                        dr_JELine["U_SAUPNO"] = FN.GetRecordsetValue(string.Format("SELECT (CASE WHEN A.U_RRNYN = 'Y' THEN A.U_RRN ELSE A.VATRegNum END) AS SAUPNO FROM OCRD AS A WHERE A.CARDCODE = '{0}'", U_BPCD));
                    }
                    if (FN.GetUserFieldValidation("JDT1", "SUPAMT"))
                    {
                        dr_JELine["U_SUPAMT"] = U_AMTBP;
                    }

                    if (FN.GetUserFieldValidation("JDT1", "VAT"))
                    {
                        dr_JELine["U_VAT"] = U_VAT;
                    }
                    #endregion

                    dt_JELines.Rows.Add(dr_JELine);
                }

                //대변
                dr_JELine = dt_JELines.NewRow();
                dr_JELine["AccountCode"] = U_ACCTCD;
                dr_JELine["ShortName"] = U_BPCD;
                dr_JELine["Credit"] = U_AMTBP + U_VAT;

                dr_JELine["CostingCode"] = U_OCRCD1;
                //dr_JELine["CostingCode2"] = U_OCRCD2;
                //dr_JELine["CostingCode3"] = U_OCRCD3;
                //dr_JELine["CostingCode4"] = U_OCRCD4;
                //dr_JELine["CostingCode5"] = U_OCRCD5;

                dt_JELines.Rows.Add(dr_JELine);


            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 25
0
        // Creates an Table instance and adds its children.
        public static Table GenerateTable(Document doc, System.Data.DataTable datetable)
        {
            Table table = new Table();
            //
            PageSize pagesize = doc.Body.Descendants<PageSize>().First();
            PageMargin pagemargin = doc.Body.Descendants<PageMargin>().First();
            //
            var AvailableSumWidth = (int)(pagesize.Width - pagemargin.Right - pagemargin.Left);

            TableBorders tborder = new Func<TableBorders>(delegate()
            {
                TableBorders tableBorders1 = new TableBorders();
                TopBorder topBorder1 = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };
                InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)4U, Space = (UInt32Value)0U };

                tableBorders1.Append(topBorder1);
                tableBorders1.Append(leftBorder1);
                tableBorders1.Append(bottomBorder1);
                tableBorders1.Append(rightBorder1);
                tableBorders1.Append(insideHorizontalBorder1);
                tableBorders1.Append(insideVerticalBorder1);
                return tableBorders1;
            })();

            table.AppendChild<TableProperties>(new TableProperties(
               new TableStyle() { Val = "a7" },
               tborder,
               new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto },
               new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }
            ));

            int sumColumn = datetable.Columns.Count;

            int averwidth = AvailableSumWidth / sumColumn;

            Double set_colSumW = 0;
            int remainSumW = 0;
            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                Object col_w = item.ExtendedProperties["width"];
                if (col_w != null) { set_colSumW += Convert.ToDouble(col_w); remainSumW += averwidth; }
            }

            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                Object col_w = item.ExtendedProperties["width"];
                if (col_w != null) item.ExtendedProperties.Add("WordWidth", Math.Floor((remainSumW * Convert.ToDouble(col_w) / set_colSumW)));
                else item.ExtendedProperties.Add("WordWidth", averwidth);
            }

            for (int i = 0; i < sumColumn; i++)
            {
                int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);
                table.AppendChild<GridColumn>(new GridColumn() { Width = col_w.ToString() });
            }
            List<System.Data.DataRow> lstCol = new List<System.Data.DataRow>();
            System.Data.DataRow dr = datetable.NewRow();
            List<object> lstObj = new List<object>();

            foreach (System.Data.DataColumn item in datetable.Columns)
            {
                lstObj.Add(item.ColumnName);
            }

            dr.ItemArray = lstObj.ToArray();
            datetable.Rows.InsertAt(dr, 0);

            foreach (System.Data.DataRow item in datetable.Rows)
            {
                TableRow tableRow = new TableRow() { RsidTableRowAddition = "00D24D12", RsidTableRowProperties = "00D24D12" };
                for (int i = 0; i < sumColumn; i++)
                {
                    int col_w = Convert.ToInt32(datetable.Columns[i].ExtendedProperties["WordWidth"]);

                    string cellValue = item[i].ToString();
                    TableCell tableCell1 = new TableCell();

                    TableCellProperties tableCellProperties1 = new TableCellProperties();
                    TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = col_w.ToString(), Type = TableWidthUnitValues.Dxa };

                    tableCellProperties1.Append(tableCellWidth1);

                    Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00D24D12", RsidParagraphProperties = "003246FB", RsidRunAdditionDefault = "00D24D12" };

                    Run run1 = new Run();

                    RunProperties runProperties1 = new RunProperties();
                    RunFonts runFonts1 = new RunFonts() { Hint = FontTypeHintValues.EastAsia };

                    runProperties1.Append(runFonts1);
                    Text text1 = new Text();
                    text1.Text = cellValue;

                    run1.Append(runProperties1);
                    run1.Append(text1);
                    BookmarkStart bookmarkStart1 = new BookmarkStart();
                    BookmarkEnd bookmarkEnd1 = new BookmarkEnd();

                    paragraph1.Append(run1);
                    paragraph1.Append(bookmarkStart1);
                    paragraph1.Append(bookmarkEnd1);

                    tableCell1.Append(tableCellProperties1);
                    tableCell1.Append(paragraph1);

                    tableRow.Append(tableCell1);
                }
                table.Append(tableRow);
            }
            return table;
        }
Esempio n. 26
0
        public bool WriteExcelDateDatabase(ref System.Data.DataTable dt)
        {
            bool IsSuccess = false;

            Excel.Application exapp = new Excel.Application(); ;  //'定义excel应用程序

            Excel.Workbook exbook = null;//       '定义工作簿
            Excel.Worksheet exsheet2 = null;//      数据工作簿
            Excel.Worksheet exsheet1 = null;//指导工作

            System.Array w_ArrayData = null;//需要导出的数组

            int w_ExcelMaxRow = 0;//excel最大行

            int w_ExcelMaxCol = 0;//excel最大列


            ////区域信息
            //Object oBooks = exapp.Workbooks;
            //System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("ja-JP");
            //oBooks.GetType().InvokeMember("Add", System.Reflection.BindingFlags.InvokeMethod, null, oBooks, null, ci);
            try
            {

                exapp.Visible = false;
                exapp.UserControl = true;
                //打开excel
                exbook = exapp.Workbooks.Open(FileName, Missing, Missing, Missing, Missing, Missing, Missing
                                                , Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);
                //从excel中获取sheet数据
                foreach (Excel.Worksheet item in exbook.Worksheets)
                {
                    if (item.Name == Sheet2Name)
                    {
                        if (exsheet2 == null)
                            exsheet2 = item;

                    }
                    //else if (item.Name == Sheet1Name)
                    //{
                    //    if (exsheet1 == null)
                    //        exsheet1 = item;
                    //}
                    //if (exsheet1 != null && exsheet2 != null)
                    //    break;
                    if (exsheet2 != null)
                        break;
                }

                //读取使用的最大的行数/列

                w_ExcelMaxRow = exsheet2.UsedRange.Rows.Count;
                w_ExcelMaxCol = exsheet2.UsedRange.Columns.Count;
                w_ArrayData = (System.Array)exsheet2.get_Range(exsheet2.Cells[StartRowIndex, 1], exsheet2.Cells[w_ExcelMaxRow, w_ExcelMaxCol]).Value2;
                //for (int i = 0; i < w_ArrayData.Length; i++)
                //{
                //    string tt = w_ArrayData.GetValue(0, 2);
                //}
                DataRow dr;
                for (int i = 0; i < w_ExcelMaxRow - StartRowIndex + 1; i++)
                {
                    dr = dt.NewRow();
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        dr[j] = w_ArrayData.GetValue(i + 1, j + 1);
                    }
                    dt.Rows.Add(dr);

                }
                dt.AcceptChanges();
                //退出excel
                exbook.Close(false, Missing, Missing);
                IsSuccess = true;

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                exbook = null;
                exapp.Quit();
                exapp = null;
                GC.Collect();
            }
            return IsSuccess;
        }
Esempio n. 27
0
        /// <summary>
        /// copies the economies data from a "EDStation"-object to "tbStationEconomy"-table
        /// </summary>
        /// <param name="StationObject"></param>
        /// <param name="EconomyRow"></param>
        /// <param name=""></param>
        private void CopyEDStationEconomiesToDataRows(EDStation StationObject, System.Data.DataTable EconomyTable)
        {
            try
            {

                // get all existing economies from the database (memory list)
                List<DataRow> Existing = EconomyTable.Select("station_id = " + StationObject.Id).ToList();

                foreach (String Economy in StationObject.Economies)
                {
                    // get the current new economy id
                    Int32 EconomyID = (Int32)DBConvert.From(BaseTableNameToID("economy", Economy));

                    // and check, if it is already existing
                    var Found = from DataRow relevantEconomy in Existing
                                where relevantEconomy.Field<Int32>("economy_id") == EconomyID
                                select relevantEconomy;
 
                    // if it's not existing, insert it
                    if(Found.Count() == 0)
                    {
                        DataRow newRow = EconomyTable.NewRow();

                        newRow["station_id"]        = StationObject.Id;
                        newRow["economy_id"]        = EconomyID;

                        EconomyTable.Rows.Add(newRow);

                    }
                    else
                    {
                        Existing.Remove(Found.First());
                    }
                }

                // remove all old, not more existing data
                foreach (DataRow RemovedRow in Existing)
                    EconomyTable.Rows.Remove(RemovedRow);    

            }
            catch (Exception ex)
            {
                throw new Exception("Error while copying station economy data", ex);
            }
        }
Esempio n. 28
0
        private void SetJournalEntries_Line_TR00411(ref System.Data.DataTable dt_JELines, string U_CARDCD, string U_ACCTCD, double U_AMT)
        {

            string edtACCTCD = oForm.DataSources.UserDataSources.Item("edtACCTCD").Value;//출금계좌계정
            string edtPRCCD = oForm.DataSources.UserDataSources.Item("edtPRCCD").Value;//코스트센터

            string U_OCRCD1 = edtPRCCD;
            string U_OCRCD2 = string.Empty;
            string U_OCRCD3 = string.Empty;
            string U_OCRCD4 = string.Empty;
            string U_OCRCD5 = string.Empty;

            try
            {
                System.Data.DataRow dr_JELine = null;

                //차변
                dr_JELine = dt_JELines.NewRow();
                dr_JELine["AccountCode"] = U_ACCTCD;
                dr_JELine["ShortName"] = U_ACCTCD;
                dr_JELine["Debit"] = U_AMT;

                dr_JELine["CostingCode"] = U_OCRCD1;
                //dr_JELine["CostingCode2"] = U_OCRCD2;
                //dr_JELine["CostingCode3"] = U_OCRCD3;
                //dr_JELine["CostingCode4"] = U_OCRCD4;
                //dr_JELine["CostingCode5"] = U_OCRCD5;

                dt_JELines.Rows.Add(dr_JELine);


                //대변
                dr_JELine = dt_JELines.NewRow();
                dr_JELine["AccountCode"] = edtACCTCD;
                dr_JELine["ShortName"] = edtACCTCD;
                dr_JELine["Credit"] = U_AMT;

                dr_JELine["CostingCode"] = U_OCRCD1;
                //dr_JELine["CostingCode2"] = U_OCRCD2;
                //dr_JELine["CostingCode3"] = U_OCRCD3;
                //dr_JELine["CostingCode4"] = U_OCRCD4;
                //dr_JELine["CostingCode5"] = U_OCRCD5;

                dt_JELines.Rows.Add(dr_JELine);

            }
            catch (Exception)
            {

                throw;
            }
        }
        private System.Data.DataTable BuildTableRows(Google.Apis.Analytics.v3.Data.GaData gaData, System.Data.DataTable table)
        {
            if (gaData.Rows == null) return table;

            foreach (var ls in gaData.Rows)
            {
                System.Data.DataRow row = table.NewRow();
                for(int i = 0; i < ls.Count(); i++)
                {
                    if (table.Columns[i].DataType == typeof(DateTime))
                    {
                        row[i] = DateTime.ParseExact(ls[i], "yyyyMMdd", CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        row[i] = ls[i];
                    }
                }
                table.Rows.Add(row);
            }
            return table;
        }
Esempio n. 30
0
        /// <summary>
        /// Build a DataTable for the form's datagrid from the
        /// existing TableMappings.
        /// </summary>
        /// <param name="dt">2-column DataTable to hold the names.</param>
        /// <param name="mapList">TableMapping collection usually
        /// from the DataAdapter.</param>
        /// <returns></returns>
        private bool BuildMapFromExistingMap(
			System.Data.DataTable dt, DataTableMappingCollection mapList)
        {
            DataTableMapping map = mapList[0];
            string sourceTable = map.SourceTable;
            string datasetTable= map.DataSetTable;
            comboBoxSourceTable.Text = sourceTable;
            textBoxDatasetTable.Text = datasetTable;

            // copy the column mappings to the 2-column DataTable
            // that will be the DataSource for the datagrid
            foreach (DataColumnMapping colMap in map.ColumnMappings)
            {
                System.Data.DataRow datarow = dt.NewRow();
                datarow[ TableMappings.SOURCE_COLUMNS  ] = colMap.SourceColumn;
                datarow[ TableMappings.DATASET_COLUMNS ] = colMap.DataSetColumn;
                dt.Rows.Add( datarow );
            }

            return true;
        }