/// <summary> /// 메트릭스에서 하나씩 추가할때 사용 /// </summary> /// <param name="oForm"></param> /// <param name="oMatrix"></param> /// <param name="oDB"></param> /// <param name="pIndex"></param> /// <param name="pDelivCd"></param> /// <param name="KeyAlias"></param> private void SetMatrixAddRow(ref SAPbouiCOM.Form oForm, ref SAPbouiCOM.Matrix oMatrix, ref SAPbouiCOM.DBDataSource oDB, string pIndex, string pDelivCd, string KeyAlias = "LineId") { try { string bindAlias = ""; string value = string.Empty; oMatrix.FlushToDataSource(); if (KeyAlias != "") { if (oDB.Size > 0) { if (oDB.GetValue(KeyAlias, oDB.Size - 1).Trim() == "") { //if (!(oMatrix.VisualRowCount == 0 && oDB.Size == 1)) //{ // oDB.InsertRecord(oDB.Size); //} } else { oDB.InsertRecord(oDB.Size); } } else { oDB.InsertRecord(oDB.Size); } } else { oDB.InsertRecord(oDB.Size); } oDB.Offset = oDB.Size - 1; for (int iLooper = 0; iLooper < oMatrix.Columns.Count; iLooper++) { if (oMatrix.Columns.Item(iLooper).UniqueID.StartsWith("U_")) { if (oMatrix.Columns.Item(iLooper).DataBind.DataBound == true && !string.IsNullOrEmpty(oMatrix.Columns.Item(iLooper).DataBind.TableName)) { bindAlias = oMatrix.Columns.Item(iLooper).DataBind.Alias.ToString(); switch (oDB.Fields.Item(bindAlias).Type) { case BoFieldsType.ft_AlphaNumeric: case BoFieldsType.ft_Date: case BoFieldsType.ft_NotDefined: case BoFieldsType.ft_Text: value = ""; break; case BoFieldsType.ft_Float: case BoFieldsType.ft_Integer: case BoFieldsType.ft_Measure: case BoFieldsType.ft_Percent: case BoFieldsType.ft_Price: case BoFieldsType.ft_Quantity: case BoFieldsType.ft_Rate: case BoFieldsType.ft_ShortNumber: case BoFieldsType.ft_Sum: value = "0"; break; default: value = ""; break; } if (bindAlias == "U_IDX") { if (string.IsNullOrEmpty(pIndex) == false) oDB.SetValue(bindAlias, oDB.Offset, pIndex); } else if (bindAlias == "U_DELVCD") { if (string.IsNullOrEmpty(pDelivCd) == false) oDB.SetValue(bindAlias, oDB.Offset, pDelivCd); } else if (bindAlias == "U_STATUS") { oDB.SetValue(bindAlias, oDB.Offset, "UO"); } else if (bindAlias == "U_ADDR1") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtADDR1").Specific.value); } else if (bindAlias == "U_ADDR1_D") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtADDR1_D").Specific.value); } else if (bindAlias == "U_ADDR2") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtADDR2").Specific.value); } else if (bindAlias == "U_ADDR2_D") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtADDR2_D").Specific.value); } else if (bindAlias == "U_TEL") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtTEL").Specific.value); } else if (bindAlias == "U_MOBILE") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtMOBILE").Specific.value); } else if (bindAlias == "U_DELVFR") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("edtR_FRDT").Specific.value); } else if (bindAlias == "U_DELVCNT") { oDB.SetValue(bindAlias, oDB.Offset, "1"); SetSumNumberOfCofies(oForm); } else if (bindAlias == "U_PAPERTP") { oDB.SetValue(bindAlias, oDB.Offset, oForm.Items.Item("cboPAPERCD").Specific.value); } else if (bindAlias == "U_JOINDT") { string strNowDate = B1Connections.theAppl.Company.ServerDate; oDB.SetValue(bindAlias, oDB.Offset, FN.SetDateFormatToDB(strNowDate, FN.eDateType.n_YYYYMMDD)); } else { oDB.SetValue(bindAlias, oDB.Offset, value); } } } } oMatrix.LoadFromDataSource(); if (oMatrix.GetNextSelectedRow() != -1) { oMatrix.ClearSelections(); } oMatrix.SelectRow(oMatrix.VisualRowCount, true, false); } catch (Exception ex) { B1Connections.theAppl.StatusBar.SetText("SetMatrixAddRow " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } }
/// <summary> /// DbDataSource에서 일괄적으로 추가할때 사용 /// </summary> /// <param name="oForm"></param> /// <param name="oMatrix"></param> /// <param name="oDB"></param> /// <param name="pKeyAlias"></param> private void SetDbDataSourceAddRow(ref SAPbouiCOM.Form oForm, ref SAPbouiCOM.Matrix oMatrix, ref SAPbouiCOM.DBDataSource oDB, string pKeyAlias = "") { string bindAlias = ""; string value = string.Empty; try { if (pKeyAlias != "") { if (oDB.Size > 0) { if (oDB.GetValue(pKeyAlias, oDB.Size - 1).Trim() == "") { //if (!(oMatrix.VisualRowCount == 0 && oDB.Size == 1)) //{ // oDB.InsertRecord(oDB.Size); //} } else { oDB.InsertRecord(oDB.Size); } } else { oDB.InsertRecord(oDB.Size); } } else { oDB.InsertRecord(oDB.Size); } oDB.Offset = oDB.Size - 1; for (int iLooper = 0; iLooper < oMatrix.Columns.Count; iLooper++) { if (oMatrix.Columns.Item(iLooper).UniqueID.StartsWith("U_")) { if (oMatrix.Columns.Item(iLooper).DataBind.DataBound == true && !string.IsNullOrEmpty(oMatrix.Columns.Item(iLooper).DataBind.TableName)) { bindAlias = oMatrix.Columns.Item(iLooper).DataBind.Alias.ToString(); switch (oDB.Fields.Item(bindAlias).Type) { case BoFieldsType.ft_AlphaNumeric: case BoFieldsType.ft_Date: case BoFieldsType.ft_NotDefined: case BoFieldsType.ft_Text: value = ""; break; case BoFieldsType.ft_Float: case BoFieldsType.ft_Integer: case BoFieldsType.ft_Measure: case BoFieldsType.ft_Percent: case BoFieldsType.ft_Price: case BoFieldsType.ft_Quantity: case BoFieldsType.ft_Rate: case BoFieldsType.ft_ShortNumber: case BoFieldsType.ft_Sum: value = "0"; break; default: value = ""; break; } if (bindAlias == "U_PROSTAT") oDB.SetValue(bindAlias, oDB.Offset, "O"); else oDB.SetValue(bindAlias, oDB.Offset, value); } } } //oMatrix.LoadFromDataSource(); } catch (Exception) { throw; } }
/// <summary> /// DataTable에서 선택한 줄만 복사 /// </summary> /// <param name="toDT">복사대상</param> /// <param name="fromDT">복사원본 DataTable</param> /// <param name="rowidx">복사원본에서 복사할 줄</param> public void CopyRowDT(ref SAPbouiCOM.DataTable toDT, SAPbouiCOM.DataTable fromDT, int? rowidx) { if (string.IsNullOrEmpty(rowidx.ToString())) { //toDT.Clear(); toDT.CopyFrom(fromDT); } else { toDT.Rows.Add(); for (int colIdx = 0; colIdx < fromDT.Columns.Count; colIdx++) { toDT.SetValue(colIdx, toDT.Rows.Count - 1, fromDT.GetValue(colIdx, Convert.ToInt32(rowidx))); } } }
private void SetMatrixAddRow(ref SAPbouiCOM.Form oForm, ref SAPbouiCOM.Matrix oMatrix, ref SAPbouiCOM.DBDataSource oDB, string KeyAlias = "LineId") { System.Data.DataRow dr = null; ; try { string bindAlias = ""; string value = string.Empty; oMatrix.FlushToDataSource(); if (oDB.Size > 0) { if (oDB.GetValue(KeyAlias, oDB.Size - 1).Trim() != "") { oDB.InsertRecord(oDB.Size); } } else { oDB.InsertRecord(oDB.Size); } oDB.Offset = oDB.Size - 1; for (int iLooper = 0; iLooper < oMatrix.Columns.Count; iLooper++) { if (oMatrix.Columns.Item(iLooper).UniqueID.StartsWith("U_")) { if (oMatrix.Columns.Item(iLooper).DataBind.DataBound == true && !string.IsNullOrEmpty(oMatrix.Columns.Item(iLooper).DataBind.TableName)) { bindAlias = oMatrix.Columns.Item(iLooper).DataBind.Alias.ToString(); switch (oDB.Fields.Item(bindAlias).Type) { case BoFieldsType.ft_AlphaNumeric: case BoFieldsType.ft_Date: case BoFieldsType.ft_NotDefined: case BoFieldsType.ft_Text: value = ""; break; case BoFieldsType.ft_Float: case BoFieldsType.ft_Integer: case BoFieldsType.ft_Measure: case BoFieldsType.ft_Percent: case BoFieldsType.ft_Price: case BoFieldsType.ft_Quantity: case BoFieldsType.ft_Rate: case BoFieldsType.ft_ShortNumber: case BoFieldsType.ft_Sum: value = "0"; break; default: value = ""; break; } if (bindAlias == "U_CIDX") { oDB.SetValue(bindAlias, oDB.Offset, oDB.Offset.ToString()); } else if (bindAlias == "U_PIDX") { oDB.SetValue(bindAlias, oDB.Offset, (-1).ToString()); } else if (bindAlias == "U_DATE") { string strNow = B1Connections.diCompany.GetCompanyDate().ToShortDateString(); oDB.SetValue(bindAlias, oDB.Offset, FN.SetDateFormatToDB(strNow, FN.eDateType.n_YYYYMMDD)); } else if (bindAlias == "U_ADVRECV") { oDB.SetValue(bindAlias, oDB.Offset, value); } else if (bindAlias == "U_ADVSUBT") { oDB.SetValue(bindAlias, oDB.Offset, value); } else { oDB.SetValue(bindAlias, oDB.Offset, value); } } } } oMatrix.LoadFromDataSource(); } catch (Exception ex) { B1Connections.theAppl.StatusBar.SetText("SetMatrixAddRow " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } }
private int GetCellsSummations(SAPbouiCOM.DataTable dtControl, string ItemCode, string whsCode, string cellName) { int totalBatches = 0; for (int i = 0; i < dtControl.Rows.Count; i++) { if ((string)dtControl.GetValue("ItemCode", i) == ItemCode && (string)dtControl.GetValue("WhsCode", i) == whsCode) { var quantity = Convert.ToInt32(dtControl.GetValue("Quantity", i)); totalBatches += quantity; } } return totalBatches; }
/// <summary> /// Create a new SAP Datatable and copy the contents from the table passed as parameter /// </summary> /// <param name="tempBatches">DataTable to copy from</param> /// <returns>Return a new SAP DataTable</returns> private System.Data.DataTable CopySelectedBatchesDataTable(SAPbouiCOM.DataTable tempBatches) { System.Data.DataTable newDataTable = new System.Data.DataTable(); newDataTable.Columns.Add("Batch", typeof(string)); newDataTable.Columns.Add("Selected Qty", typeof(string)); for (int x = 0; x < tempBatches.Rows.Count; x++) { System.Data.DataRow dr = newDataTable.NewRow(); var batchValue = tempBatches.GetValue("Batch", x); var batchQuantity = tempBatches.GetValue("Selected Qty", x); if (batchValue.ToString() != string.Empty && batchQuantity.ToString() != string.Empty) { dr["Batch"] = tempBatches.GetValue("Batch", x); dr["Selected Qty"] = tempBatches.GetValue("Selected Qty", x); newDataTable.Rows.Add(dr); } } return newDataTable; }
/// <summary> /// Create a new SAP Datatable and copy the contents from the table passed as parameter /// </summary> /// <param name="tempBatches">DataTable to copy from</param> /// <returns>Return a new SAP DataTable</returns> private System.Data.DataTable CopyBatchesDataTable(SAPbouiCOM.DataTable tempBatches) { System.Data.DataTable newDataTable = new System.Data.DataTable(); newDataTable.Columns.Add("ItemCode", typeof(string)); newDataTable.Columns.Add("DistNumber", typeof(string)); newDataTable.Columns.Add("Quantity", typeof(string)); newDataTable.Columns.Add("WhsCode", typeof(string)); newDataTable.Columns.Add("AvgPrice", typeof(double)); newDataTable.Columns.Add("Selected Qty", typeof(string)); for (int x = 0; x < tempBatches.Rows.Count; x++) { System.Data.DataRow dr = newDataTable.NewRow(); dr["ItemCode"] = tempBatches.GetValue("ItemCode", x); dr["DistNumber"] = tempBatches.GetValue("DistNumber", x); dr["Quantity"] = tempBatches.GetValue("Quantity", x); dr["WhsCode"] = tempBatches.GetValue("WhsCode", x); dr["AvgPrice"] = tempBatches.GetValue("AvgPrice", x); dr["Selected Qty"] = tempBatches.GetValue("Selected Qty", x); ; newDataTable.Rows.Add(dr); } return newDataTable; }
/// <summary> /// 광고수주오더의 DBDatasource 정보를 광고매출확정 DBdataSource에 복제합니다.(라인) /// </summary> /// <param name="oKIS_SD00301_HRD">광고주수오더 행 DBDataSource</param> /// <param name="oKIS_SD00501_HRD">광고매출확정 행 DBDataSource</param> private void SetDBDataSourceCopy_Line(SAPbouiCOM.DBDataSource oKIS_SD00301_HRD, SAPbouiCOM.DBDataSource oKIS_SD00501_HRD) { try { List<string> list_KIS_SD00501_HRD = new List<string>(); for (int iLooper = 0; iLooper < oKIS_SD00501_HRD.Fields.Count; iLooper++) { string FieldName = oKIS_SD00501_HRD.Fields.Item(iLooper).Name; //사용자 정의 필드만 복사 대상필드 리스트에 추가 if (FieldName.StartsWith("U_")) { list_KIS_SD00501_HRD.Add(oKIS_SD00501_HRD.Fields.Item(iLooper).Name); } } //라인 int iCount = 0; for (int jLooper = 0; jLooper < oKIS_SD00301_HRD.Size; jLooper++) { oKIS_SD00301_HRD.Offset = jLooper; if (oKIS_SD00501_HRD.Size - 1 < iCount) { oKIS_SD00501_HRD.InsertRecord(oKIS_SD00501_HRD.Size); } oKIS_SD00501_HRD.Offset = iCount; //행상태가 미결인 것만 가져오기 if (oKIS_SD00301_HRD.GetValue("U_STATUS", oKIS_SD00301_HRD.Offset).Trim() == "O") { iCount++; } else { continue; } //컬럼 for (int iLooper = 0; iLooper < oKIS_SD00301_HRD.Fields.Count; iLooper++) { string FieldName = oKIS_SD00301_HRD.Fields.Item(iLooper).Name; if (list_KIS_SD00501_HRD.Contains(FieldName)) { switch (FieldName) { case "U_AMT": oKIS_SD00501_HRD.SetValue(FieldName, oKIS_SD00501_HRD.Offset, oKIS_SD00301_HRD.GetValue("U_OPENAMT", oKIS_SD00301_HRD.Offset).Trim()); break; case "U_BTYPE"://기준문서유형 oKIS_SD00501_HRD.SetValue(FieldName, oKIS_SD00501_HRD.Offset, oKIS_SD00301_HRD.GetValue("Object", oKIS_SD00301_HRD.Offset).Trim()); break; case "U_BENTRY"://기준문서엔트리 oKIS_SD00501_HRD.SetValue(FieldName, oKIS_SD00501_HRD.Offset, oKIS_SD00301_HRD.GetValue("DocEntry", oKIS_SD00301_HRD.Offset).Trim()); break; case "U_BLINEID"://기준문서 행ID oKIS_SD00501_HRD.SetValue(FieldName, oKIS_SD00501_HRD.Offset, oKIS_SD00301_HRD.GetValue("LineId", oKIS_SD00301_HRD.Offset).Trim()); break; case "U_TTYPE": case "U_TENTRY": case "U_TLINEID": oKIS_SD00501_HRD.SetValue(FieldName, oKIS_SD00501_HRD.Offset, ""); break; default: oKIS_SD00501_HRD.SetValue(FieldName, oKIS_SD00501_HRD.Offset, oKIS_SD00301_HRD.GetValue(FieldName, oKIS_SD00301_HRD.Offset).Trim()); break; } } } } oMatrix = oForm.Items.Item("mtx1").Specific; oMatrix.LoadFromDataSource(); //분할된 미결금액이 있을지도 모르니까, 매출금액 기준으로 다시 재계산 시작 for (int iLooper = 1; iLooper < oMatrix.VisualRowCount; iLooper++) { SetCalc("U_AMT", iLooper); } SetMatrixCalc_Sum(); list_KIS_SD00501_HRD = null; } catch (Exception) { throw; } }
/// <summary> /// 광고수주오더의 DBDatasource 정보를 광고매출확정 DBdataSource에 복제합니다.(헤더) /// </summary> /// <param name="oKIS_SD0030T_HRD">광고수주오더 헤더 DBDataSource</param> /// <param name="oKIS_SD0050T_HRD">광고매출확정 헤더 DBDataSource</param> private static void SetDBDataSourceCopy_Header(SAPbouiCOM.DBDataSource oKIS_SD0030T_HRD, SAPbouiCOM.DBDataSource oKIS_SD0050T_HRD) { try { List<string> list_KIS_SD0050T_HRD = new List<string>(); for (int iLooper = 0; iLooper < oKIS_SD0050T_HRD.Fields.Count; iLooper++) { string FieldName = oKIS_SD0050T_HRD.Fields.Item(iLooper).Name; //사용자 정의 필드만 복사 대상필드 리스트에 추가 if (FieldName.StartsWith("U_")) { list_KIS_SD0050T_HRD.Add(oKIS_SD0050T_HRD.Fields.Item(iLooper).Name); } } for (int iLooper = 0; iLooper < oKIS_SD0030T_HRD.Fields.Count; iLooper++) { string FieldName = oKIS_SD0030T_HRD.Fields.Item(iLooper).Name; if (list_KIS_SD0050T_HRD.Contains(FieldName)) { oKIS_SD0050T_HRD.SetValue(FieldName, 0, oKIS_SD0030T_HRD.GetValue(FieldName, 0).Trim()); //전기일을 매출일과 동일하게 입력합니다. //매출일은 광고매출 확정 문서에만 존재합니다. if (FieldName == "U_DOCDT") { oKIS_SD0050T_HRD.SetValue("U_SALDT", 0, oKIS_SD0030T_HRD.GetValue(FieldName, 0).Trim()); } } } } catch (Exception) { throw; } }