Beispiel #1
0
        /// <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);
            }
        }