Пример #1
0
        /// <summary>
        /// Загружает приложение к расчету
        /// </summary>
        public void LoadCalcOrderItems()
        {
            if (m_objCalcOrder == null)
            {
                return;
            }
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                ((System.ComponentModel.ISupportInitialize)(this.treeList)).BeginInit();
                this.SuspendLayout();
                treeList.CellValueChanged -= new DevExpress.XtraTreeList.CellValueChangedEventHandler(treeList_CellValueChanged);
                treeList.Nodes.Clear();

                if (m_objCalcOrder.CalcOrderItemList == null)
                {
                    m_objCalcOrder.CalcOrderItemList = CCalcOrderItem.GetCalcOrderItemList(m_objProfile, null, m_objCalcOrder.ID);
                }

                if ((m_objCalcOrder.CalcOrderItemList != null) && (m_objCalcOrder.CalcOrderItemList.Count > 0))
                {
                    treeList.DataSource = m_objCalcOrder.CalcOrderItemList;
                }

                if (treeList.Nodes.Count > 0)
                {
                    treeList.FocusedNode = treeList.Nodes[0];
                }
            }//try
            catch (System.Exception f)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    "Ошибка построения содержимого расчета заказа.\nТекст ошибки: " + f.Message, "Ошибка",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;
                ((System.ComponentModel.ISupportInitialize)(this.treeList)).EndInit();
                this.ResumeLayout(false);
                SetPropertiesModified(false);
                treeList.CellValueChanged += new DevExpress.XtraTreeList.CellValueChangedEventHandler(treeList_CellValueChanged);
            }

            return;
        }
Пример #2
0
        /// <summary>
        /// Возвращает приложение к расчету
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список расчетов</returns>
        public static List<CCalcOrderItem> GetCalcOrderItemList(UniXP.Common.CProfile objProfile,
            System.Data.SqlClient.SqlCommand cmdSQL, System.Guid CalcOrderID)
        {
            List<CCalcOrderItem> objList = new List<CCalcOrderItem>();
            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand cmd = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        DevExpress.XtraEditors.XtraMessageBox.Show(
                            "Не удалось получить соединение с базой данных.", "Внимание",
                            System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return objList;
                    }
                    cmd = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetCalcOrderListItemsFromERP_Report]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CALCORDER_GUID", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000));
                cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;
                cmd.Parameters["@CALCORDER_GUID"].Value = CalcOrderID;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CProduct objProduct = null;
                    CCurrency objCurrency = null;
                    CCountry objCountry = null;
                    CProductTradeMark objProductTradeMark = null;
                    CProductType objProductType = null;
                    CProductSubType objProductSubType = null;
                    CMeasure objMeasure = null;
                    CCalcOrderItem objCalcOrderItem = null;

                    while (rs.Read())
                    {
                        objCurrency = null;
                        objCountry = null;
                        objProductTradeMark = null;
                        objProductType = null;
                        objProductSubType = null;
                        // товарная марка
                        objProductTradeMark = new CProductTradeMark();
                        objProductTradeMark.Name = (System.String)rs["OWNER_NAME"];
                        objProductTradeMark.ID_Ib = System.Convert.ToInt32(rs["OWNER_ID"]);
                        objProductTradeMark.ProductVtm = new CProductVtm();
                        objProductTradeMark.ProductVtm.ID_Ib = System.Convert.ToInt32(rs["VTM_ID"]);
                        objProductTradeMark.ProductVtm.Name = (System.String)rs["VTM_NAME"];
                        objProductTradeMark.ProcessDayCount = System.Convert.ToInt32(rs["OWNER_PROCESSDAYSCOUNT"]);
                        // товарная группа
                        objProductType = new CProductType();
                        objProductType.ID_Ib = System.Convert.ToInt32(rs["PARTTYPE_ID"]);
                        objProductType.Name = (System.String)rs["PARTTYPE_NAME"];
                        // товарная подгруппа
                        objProductSubType = new CProductSubType();
                        objProductSubType.ID_Ib = System.Convert.ToInt32(rs["PARTSUBTYPE_ID"]);
                        objProductSubType.Name = (System.String)rs["PARTSUBTYPE_NAME"];
                        objProductSubType.ProductLine = new CProductLine();
                        objProductSubType.ProductLine.ID_Ib = System.Convert.ToInt32(rs["PARTSECSUBTYPE_ID"]);    
                        objProductSubType.ProductLine.Name = (System.String)rs["PARTSECSUBTYPE_NAME"];
                        // страна производства
                        objCountry = new CCountry();
                        if (rs["COUNTRY_PROD_ID"] != System.DBNull.Value)
                        {
                            objCountry.Name = (System.String)rs["COUNTRY_NAME"];
                        }
                        // валюта
                        objCurrency = new CCurrency( System.Guid.Empty, "", ( (rs["CURRENCY_CODE"] == System.DBNull.Value) ? "" : (System.String)rs["CURRENCY_CODE"]), ""  );
                        // единица измерения
                        objMeasure = new CMeasure();
                        objMeasure.Name = (System.String)rs["MEASURE_NAME"];

                        // товар
                        objProduct = new CProduct(System.Guid.Empty, System.Convert.ToInt32(rs["PARTS_ID"]),
                            (System.String)rs["PARTS_NAME"], (System.String)rs["PARTS_ORIGNAME"],
                            (System.String)rs["PARTS_NAME"], (System.String)rs["PARTS_ARTICLE"],
                            objProductTradeMark, objProductType, objProductSubType, objCountry, objCurrency,
                            ((rs["PARTS_VENDORPRICE"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PARTS_VENDORPRICE"])),
                            ((rs["PARTS_BOXQTY"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["PARTS_BOXQTY"])),
                            ((rs["PARTS_PACKQTY"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["PARTS_PACKQTY"])),
                            ((rs["PARTS_PACKQTYFORCALC"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["PARTS_PACKQTYFORCALC"])),
                            ((rs["PARTS_WEIGHT"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PARTS_WEIGHT"])),
                            ((rs["PARTS_PAPERCONTAINERWEIGHT"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PARTS_PAPERCONTAINERWEIGHT"])),
                            ((rs["PARTS_PLASTICCONTAINERWEIGHT"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PARTS_PLASTICCONTAINERWEIGHT"])),
                            ((rs["PARTS_ALCOHOLICCONTENTPERCENT"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PARTS_ALCOHOLICCONTENTPERCENT"])),
                            true, // ((rs["Parts_IsActive"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["Parts_IsActive"])),
                            ((rs["PARTS_NOTVALID"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["PARTS_NOTVALID"])),
                            ((rs["PARTS_ACTUALNOTVALID"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["PARTS_ACTUALNOTVALID"])),
                            "", //((rs["Parts_Certificate"] == System.DBNull.Value) ? "" : (System.String)rs["Parts_Certificate"]),
                            ((rs["PARTS_CODETNVD"] == System.DBNull.Value) ? "" : (System.String)rs["PARTS_CODETNVD"]),
                            ((rs["PARTS_REFERENCE"] == System.DBNull.Value) ? "" : (System.String)rs["PARTS_REFERENCE"]),
                            objMeasure, null, 0
                            );
                        if (rs["PARTS_BARCODE"] != System.DBNull.Value)
                        {
                            objProduct.BarcodeList = new List<string>();
                            objProduct.BarcodeList.Add((System.String)rs["PARTS_BARCODE"]);
                        }
                        objCalcOrderItem = new CCalcOrderItem();
                        objCalcOrderItem.objProduct = objProduct;
                        objCalcOrderItem.PartsIsNew = System.Convert.ToBoolean(rs["PARTS_IS_NEW"]);
                        objCalcOrderItem.PLAN_FOR_3MONTH = ((rs["PLAN_FOR_3MONTH"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PLAN_FOR_3MONTH"]));
                        objCalcOrderItem.PLAN_FOR_3MONTH_IN_WEEK_AVG = ((rs["PLAN_FOR_3MONTH_IN_WEEK_AVG"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PLAN_FOR_3MONTH_IN_WEEK_AVG"]));
                        objCalcOrderItem.PREDICTION_FOR_3MONTH = ((rs["PREDICTION_FOR_3MONTH"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PREDICTION_FOR_3MONTH"]));
                        objCalcOrderItem.PREDICTION_FOR_3MONTH_IN_WEEK_AVG = ((rs["PREDICTION_FOR_3MONTH_IN_WEEK_AVG"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["PREDICTION_FOR_3MONTH_IN_WEEK_AVG"]));
                        objCalcOrderItem.SALE_FOR_3MONTH = ((rs["SALE_FOR_3MONTH"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["SALE_FOR_3MONTH"]));
                        objCalcOrderItem.SALE_FOR_3MONTH_IN_WEEK_AVG = ((rs["SALE_FOR_3MONTH_IN_WEEK_AVG"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["SALE_FOR_3MONTH_IN_WEEK_AVG"]));
                        objCalcOrderItem.QUANTITY_IN_ORDER = ((rs["QUANTITY_IN_ORDER"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["QUANTITY_IN_ORDER"]));
                        objCalcOrderItem.QUANTITY_IN_STOCK = ((rs["QUANTITY_IN_STOCK"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["QUANTITY_IN_STOCK"]));
                        objCalcOrderItem.QUANTITY_IN_WAY = ((rs["QUANTITY_IN_WAY"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["QUANTITY_IN_WAY"]));
                        objCalcOrderItem.QUANTITY_MIN_STOCK_IN_WEEK = ((rs["QUANTITY_MIN_STOCK_IN_WEEK"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["QUANTITY_MIN_STOCK_IN_WEEK"]));
                        objCalcOrderItem.KOEFF_SEASON_AVG = ((rs["KOEFF_SEASON_AVG"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["KOEFF_SEASON_AVG"]));
                        objCalcOrderItem.KOEFF_DIV = ((rs["KOEFF_DIV"] == System.DBNull.Value) ? 0 : System.Convert.ToDecimal(rs["KOEFF_DIV"]));
                        objCalcOrderItem.ABC = ((rs["ABC"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["ABC"]));
                        objList.Add(objCalcOrderItem);
                    }
                }
                rs.Dispose();

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                "Не удалось получить приложение к расчету.\n\nТекст ошибки : " + f.Message, "Внимание",
                System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return objList;
        }