Пример #1
0
        /// <summary>
        /// Возвращает список документов о качестве товара
        /// </summary>
        /// <param name="objProduct">товар</param>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список типов документов о качестве товара</returns>
        public static List <CCertificate> GetCertificateTypeList(CProduct objProduct, UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CCertificate> objList = new List <CCertificate>();

            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_GetPartsCertificate]", 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("@Parts_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["@Parts_Guid"].Value    = objProduct.ID;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                        objList.Add(new CCertificate(new CCertificateType(
                                                         (System.Guid)rs["CertificateType_Guid"],
                                                         (System.String)rs["CertificateType_Name"],
                                                         ((rs["CertificateType_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["CertificateType_Description"])),
                                                         System.Convert.ToBoolean(rs["CertificateType_IsActive"])
                                                         ), (System.Guid)rs["Certificate_Guid"], System.Convert.ToString(rs["Certificate_Num"]),
                                                     System.Convert.ToDateTime(rs["Certificate_BeginDate"]),
                                                     ((rs["Certificate_EndDate"] == System.DBNull.Value) ? System.DateTime.MaxValue : System.Convert.ToDateTime(rs["Certificate_EndDate"])),
                                                     System.Convert.ToString(rs["Certificate_WhoGive"])
                                                     )
                        {
                            NumForWaybill            = ((rs["Certificate_NumForWaybill"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Certificate_NumForWaybill"])),
                            Description              = ((rs["Certificate_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Certificate_Description"])),
                            IsActive                 = ((rs["Certificate_IsActive"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["Certificate_IsActive"])),
                            ExistImage               = ((rs["ExistImage"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["ExistImage"])),
                            ImageCertificateFileName = ((rs["Certificate_ImageFileFullName"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Certificate_ImageFileFullName"]))
                        }
                                    );
                    }
                }
                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);
        }
Пример #2
0
        /// <summary>
        /// Удаляет запись из базы данных
        /// </summary>
        /// <param name="BUDGETPROJECT_GUID">УИ проекта</param>
        /// <param name="objProfile">профайл</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - запись удалена; false - ошибка</returns>
        public static System.Boolean RemoveObjectFromDataBase(System.Guid BUDGETPROJECT_GUID,
                                                              UniXP.Common.CProfile objProfile, ref System.String strErr)
        {
            System.Boolean bRet = false;

            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;

            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    strErr += ("Не удалось получить соединение с базой данных.");
                    return(bRet);
                }
                DBTransaction   = DBConnection.BeginTransaction();
                cmd             = new System.Data.SqlClient.SqlCommand();
                cmd.Connection  = DBConnection;
                cmd.Transaction = DBTransaction;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_DeleteBudgetProject]", 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("@BUDGETPROJECT_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["@BUDGETPROJECT_GUID"].Value = BUDGETPROJECT_GUID;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes == 0)
                {
                    // подтверждаем транзакцию
                    DBTransaction.Commit();
                }
                else
                {
                    DBTransaction.Rollback();
                    strErr += ((cmd.Parameters["@ERROR_MES"].Value == System.DBNull.Value) ? "" : (System.String)cmd.Parameters["@ERROR_MES"].Value);
                }

                cmd.Dispose();
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                DBTransaction.Rollback();

                strErr += ("Не удалось удалить объект 'проект'. Текст ошибки: " + f.Message);
            }
            finally
            {
                DBConnection.Close();
            }
            return(bRet);
        }
Пример #3
0
        /// <summary>
        /// Сохраняет настройку в БД
        /// </summary>
        /// <param name="uuidSettingId">УИ настройкиb</param>
        /// <param name="strInnerXml">XML-представление</param>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - удачное завершение; false - ошибка</returns>
        public static System.Boolean SaveSettingInDB(System.Guid uuidSettingId, System.String strInnerXml, UniXP.Common.CProfile objProfile,
                                                     System.Data.SqlClient.SqlCommand cmdSQL, ref System.String strErr)
        {
            System.Boolean bRet = false;
            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr = "Не удалось получить соединение с базой данных.";
                        return(bRet);
                    }
                    DBTransaction   = DBConnection.BeginTransaction();
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.Transaction = DBTransaction;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                cmd.CommandText = System.String.Format("[{0}].[dbo].[sp_SetSetting]", 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("@Settings_Guid", System.Data.SqlDbType.UniqueIdentifier, 8));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Settings_XML", System.Data.SqlDbType.Xml));
                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["@Settings_Guid"].Value = uuidSettingId;
                cmd.Parameters["@Settings_XML"].Value  = strInnerXml; //.Value;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes != 0)
                {
                    strErr = (System.String)cmd.Parameters["@ERROR_MES"].Value;
                }
                if (cmdSQL == null)
                {
                    if (iRes == 0)
                    {
                        // подтверждаем транзакцию
                        if (DBTransaction != null)
                        {
                            DBTransaction.Commit();
                        }
                    }
                    else
                    {
                        // откатываем транзакцию
                        if (DBTransaction != null)
                        {
                            DBTransaction.Rollback();
                        }
                    }
                    DBConnection.Close();
                }
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                if ((cmdSQL == null) && (DBTransaction != null))
                {
                    DBTransaction.Rollback();
                }
                strErr = f.Message;
            }
            finally
            {
                if (DBConnection != null)
                {
                    DBConnection.Close();
                }
            }
            return(bRet);
        }
Пример #4
0
        /// <summary>
        /// Возвращает настройки для импорта данных в приложение к плану
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список настроек</returns>
        public static CSettingForImportData GetSettingForImportDataInPlanByDepartCustomerSubtype(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            CSettingForImportData objRet = null;

            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(objRet);
                    }
                    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_GetImportDataInPlanByDepartCustomerSubtypeSettings]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    rs.Read();
                    {
                        objRet              = new CSettingForImportData();
                        objRet.ID           = (System.Guid)rs["Settings_Guid"];
                        objRet.Name         = System.Convert.ToString(rs["Settings_Name"]);
                        objRet.SettingsList = new List <CSettingItemForImportData>();

                        objRet.XMLSettings = new System.Xml.XmlDocument();
                        objRet.XMLSettings.LoadXml(rs.GetSqlXml(2).Value);

                        foreach (System.Xml.XmlNode objNode in objRet.XMLSettings.ChildNodes)
                        {
                            foreach (System.Xml.XmlNode objChildNode in objNode.ChildNodes)
                            {
                                objRet.SettingsList.Add(new CSettingItemForImportData()
                                {
                                    TOOLS_ID          = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_ID"].Value),
                                    TOOLS_NAME        = System.Convert.ToString(objChildNode.Attributes["TOOLS_NAME"].Value),
                                    TOOLS_USERNAME    = System.Convert.ToString(objChildNode.Attributes["TOOLS_USERNAME"].Value),
                                    TOOLS_DESCRIPTION = System.Convert.ToString(objChildNode.Attributes["TOOLS_DESCRIPTION"].Value),
                                    TOOLS_VALUE       = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_VALUE"].Value),
                                    TOOLSTYPE_ID      = System.Convert.ToInt32(objChildNode.Attributes["TOOLSTYPE_ID"].Value)
                                });
                            }
                        }
                    }
                }
                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(objRet);
        }
Пример #5
0
        /// <summary>
        /// Возвращает список объектов "Состояние возвратной накладной" из базы данных в виде таблицы значений
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>таблицу</returns>
        public static System.Data.DataTable GetBackWaybillStateList(UniXP.Common.CProfile objProfile,
                                                                    System.Data.SqlClient.SqlCommand cmdSQL, ref System.String strErr)
        {
            System.Data.DataTable dtReturn = new System.Data.DataTable();

            dtReturn.Columns.Add(new System.Data.DataColumn("BackWaybillState_Guid", typeof(System.Data.SqlTypes.SqlGuid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("BackWaybillState_Name", typeof(System.Data.SqlTypes.SqlString)));
            dtReturn.Columns.Add(new System.Data.DataColumn("BackWaybillState_Description", typeof(System.Data.SqlTypes.SqlString)));
            dtReturn.Columns.Add(new System.Data.DataColumn("BackWaybillState_IsActive", typeof(System.Data.SqlTypes.SqlBoolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("BackWaybillState_IsDefault", typeof(System.Data.SqlTypes.SqlBoolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("BackWaybillState_Id", typeof(System.Data.SqlTypes.SqlInt32)));

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("\nНе удалось получить соединение с базой данных.");
                        return(dtReturn);
                    }
                    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_GetBackWaybillState]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    System.Data.DataRow newRow = null;

                    while (rs.Read())
                    {
                        newRow = dtReturn.NewRow();
                        newRow["BackWaybillState_Guid"]        = (System.Guid)rs["BackWaybillState_Guid"];
                        newRow["BackWaybillState_Name"]        = ((rs["BackWaybillState_Name"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["BackWaybillState_Name"]));
                        newRow["BackWaybillState_Description"] = ((rs["BackWaybillState_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["BackWaybillState_Description"]));
                        newRow["BackWaybillState_IsActive"]    = ((rs["BackWaybillState_IsActive"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["BackWaybillState_IsActive"]));
                        newRow["BackWaybillState_IsDefault"]   = ((rs["BackWaybillState_IsDefault"] == System.DBNull.Value) ? false : System.Convert.ToBoolean(rs["BackWaybillState_IsDefault"]));
                        newRow["BackWaybillState_Id"]          = ((rs["BackWaybillState_Id"] == System.DBNull.Value) ? 0 : System.Convert.ToInt32(rs["BackWaybillState_Id"]));

                        dtReturn.Rows.Add(newRow);
                    }

                    dtReturn.AcceptChanges();
                }
                rs.Dispose();
                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += ("\nНе удалось получить список объектов \"состояние возвратной накладной\". Текст ошибки: " + f.Message);
            }
            return(dtReturn);
        }
Пример #6
0
        /// <summary>
        /// Запускает хранимую процедуру по расчету заказа для указанной товарной марки
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="objProductOwner">товарная марка</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - успешное завершение операции; false - ошибка</returns>
        public static System.Boolean CalcOrder(UniXP.Common.CProfile objProfile,
            System.Data.SqlClient.SqlCommand cmdSQL, ERP_Mercury.Common.CProductOwner objProductOwner, CSalePrognosis objSalePrognosis, ref System.String strErr)
        {
            System.Boolean bRet = false;
            System.Int32 iCmdTimeOut = 600;
            if (objProductOwner == null)
            {
                strErr = "Не указана товарная марка.";
                return bRet;
            }
            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand cmd = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr = "Не удалось получить соединение с базой данных.";
                        return bRet;
                    }
                    cmd = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }
                cmd.CommandTimeout = iCmdTimeOut;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_CalcOrder]", 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("@Owner_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));
                if (objSalePrognosis != null)
                {
                    cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@SALEPROGNOSIS_ID", System.Data.SqlDbType.Int));
                    cmd.Parameters["@SALEPROGNOSIS_ID"].Value = objSalePrognosis.ID;
                }
                cmd.Parameters["@Owner_Guid"].Value = objProductOwner.uuidID;
                cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@ERROR_NUM"].Value;
                strErr = (System.String)cmd.Parameters["@ERROR_MES"].Value;
                bRet = (iRes == 0);

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr = "Не удалось сформировать расчет.\n\nТекст ошибки : " + f.Message;
            }
            return bRet;
        }
Пример #7
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;
        }
Пример #8
0
        /// <summary>
        /// Возвращает таблицу с приложением к накладной на внутреннее перемещение
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">объект "SQL-команда"</param>
        /// <param name="uuidIntWaybillId">уи накладной на внутреннее перемещение</param>
        /// <param name="strErr">строка с сообщением об ошибке</param>
        /// <param name="bTableFromIntOrder">признак "приложение запрашивается из заказа на внутреннее перемещение"</param>
        /// <returns>приложение к накладной в виде объекта класса DataTable</returns>
        public static System.Data.DataTable GetIntWaybilItemTable(UniXP.Common.CProfile objProfile,
                                                                  System.Data.SqlClient.SqlCommand cmdSQL, System.Guid uuidIntWaybillId, ref System.String strErr, System.Boolean bTableFromIntOrder = false)
        {
            System.Data.DataTable dtReturn = new System.Data.DataTable();

            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillItem_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntOrderItem_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Guid", typeof(System.Guid)));

            dtReturn.Columns.Add(new System.Data.DataColumn("Parts_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Measure_Guid", typeof(System.Guid)));

            dtReturn.Columns.Add(new System.Data.DataColumn("ProductOwnerName", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PARTS_NAME", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PARTS_ARTICLE", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Measure_ShortName", typeof(System.String)));

            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_Quantity", typeof(System.Double)));

            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_Price", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_PriceImporter", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_RetailPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_Discount", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_DiscountPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_AllPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_TotalPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_RetailAllPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybItem_NDSPercent", typeof(System.Double)));

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;

            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("Не удалось получить соединение с базой данных.");
                        return(dtReturn);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                if (bTableFromIntOrder == true)
                {
                    cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybItemsFromIntOrder]", 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("@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.Add(new System.Data.SqlClient.SqlParameter("@IntOrder_Guid", System.Data.DbType.Guid));
                    cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;

                    cmd.Parameters["@IntOrder_Guid"].Value = uuidIntWaybillId;
                }
                else
                {
                    cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybItems]", 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("@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.Add(new System.Data.SqlClient.SqlParameter("@Waybill_Guid", System.Data.DbType.Guid));
                    cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;

                    cmd.Parameters["@IntWaybill_Guid"].Value = uuidIntWaybillId;
                }

                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                System.Int32 iRecordCount = 0;
                if (rs.HasRows)
                {
                    System.Data.DataRow newRow = null;
                    while (rs.Read())
                    {
                        iRecordCount++;

                        newRow = dtReturn.NewRow();

                        newRow["IntWaybItem_Guid"]  = ((rs["IntWaybItem_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntWaybItem_Guid"] : System.Guid.Empty);
                        newRow["IntOrderItem_Guid"] = ((rs["IntOrderItem_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntOrderItem_Guid"] : System.Guid.Empty);
                        newRow["IntWaybill_Guid"]   = ((rs["IntWaybill_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntWaybill_Guid"] : System.Guid.Empty);
                        newRow["IntWaybillItem_Id"] = ((rs["IntWaybillItem_Id"] != System.DBNull.Value) ? (System.Int32)rs["IntWaybillItem_Id"] : 0);
                        newRow["Measure_Guid"]      = ((rs["Measure_Guid"] != System.DBNull.Value) ? (System.Guid)rs["Measure_Guid"] : System.Guid.Empty);
                        newRow["Parts_Guid"]        = ((rs["Parts_Guid"] != System.DBNull.Value) ? (System.Guid)rs["Parts_Guid"] : System.Guid.Empty);

                        newRow["ProductOwnerName"]  = ((rs["ProductOwnerName"] != System.DBNull.Value) ? System.Convert.ToString(rs["ProductOwnerName"]) : System.String.Empty);
                        newRow["PARTS_NAME"]        = ((rs["PARTS_NAME"] != System.DBNull.Value) ? System.Convert.ToString(rs["PARTS_NAME"]) : System.String.Empty);
                        newRow["PARTS_ARTICLE"]     = ((rs["PARTS_ARTICLE"] != System.DBNull.Value) ? System.Convert.ToString(rs["PARTS_ARTICLE"]) : System.String.Empty);
                        newRow["Measure_ShortName"] = ((rs["Measure_ShortName"] != System.DBNull.Value) ? System.Convert.ToString(rs["Measure_ShortName"]) : System.String.Empty);

                        newRow["IntWaybItem_Quantity"] = rs["IntWaybItem_Quantity"];

                        newRow["IntWaybItem_Price"]         = rs["IntWaybItem_Price"];
                        newRow["IntWaybItem_PriceImporter"] = rs["IntWaybItem_PriceImporter"];
                        newRow["IntWaybItem_RetailPrice"]   = rs["IntWaybItem_RetailPrice"];
                        newRow["IntWaybItem_Discount"]      = rs["IntWaybItem_Discount"];
                        newRow["IntWaybItem_DiscountPrice"] = rs["IntWaybItem_DiscountPrice"];
                        newRow["IntWaybItem_NDSPercent"]    = rs["IntWaybItem_NDSPercent"];

                        newRow["IntWaybItem_AllPrice"]       = rs["IntWaybItem_AllPrice"];
                        newRow["IntWaybItem_TotalPrice"]     = rs["IntWaybItem_TotalPrice"];
                        newRow["IntWaybItem_RetailAllPrice"] = rs["IntWaybItem_RetailAllPrice"];

                        dtReturn.Rows.Add(newRow);
                    }

                    dtReturn.AcceptChanges();
                }
                rs.Dispose();
                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += (String.Format("\nНе удалось получить таблицу с приложением к накладной на внутреннее перемещение.\nТекст ошибки: {0}", f.Message));
            }
            return(dtReturn);
        }
Пример #9
0
        /// <summary>
        /// Возвращает таблицу с приложением к накладной на внутреннее перемещение
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">объект "SQL-команда"</param>
        /// <param name="uuidIntWaybillId">уи накладной на внутреннее перемещение</param>
        /// <param name="strErr">строка с сообщением об ошибке</param>
        /// <returns>приложение к накладной на внутреннее перемещение в виде объекта класса DataTable</returns>
        public static System.Data.DataTable GetIntWaybilItemTableForExportToExcel(UniXP.Common.CProfile objProfile,
                                                                                  System.Data.SqlClient.SqlCommand cmdSQL, System.Guid uuidIntWaybillId, ref System.String strErr)
        {
            System.Data.DataTable dtReturn = new System.Data.DataTable();

            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_ID", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PARTS_ID", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PARTS_FULLNAME", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("OWNER_NAME", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("MEASURE_SHORTNAME", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_QUANTITY", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_BASEPRICE", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_PERCENT", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_DOUBLEPERCENT", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_TOTALPRICEWITHOUTNDS", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_NDS", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_STRNDS", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_NDSTOTALPRICE", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_TOTALPRICE", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_WEIGHT", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_PLACES", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_INTPLACES", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_TARA", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_QTYINPLACE", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PARTS_CERTIFICATE", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_NOTES", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("WAYBITMS_PRICEWITHOUTNDS", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("COUNTRY_NAME", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Parts_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Parts_Barcode", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Parts_BarcodeList", typeof(System.String)));

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;

            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("Не удалось получить соединение с базой данных.");
                        return(dtReturn);
                    }
                    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_GetIntWaybillProduction4StockFromIB]", 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("@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.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_Guid", System.Data.DbType.Guid));
                cmd.Parameters["@ERROR_MES"].Direction = System.Data.ParameterDirection.Output;

                cmd.Parameters["@IntWaybill_Guid"].Value = uuidIntWaybillId;

                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                System.Int32 iRecordCount = 0;
                if (rs.HasRows)
                {
                    System.Data.DataRow newRow = null;
                    while (rs.Read())
                    {
                        iRecordCount++;

                        newRow = dtReturn.NewRow();

                        newRow["WAYBITMS_ID"]                   = rs["WAYBITMS_ID"];
                        newRow["PARTS_ID"]                      = rs["PARTS_ID"];
                        newRow["PARTS_FULLNAME"]                = rs["PARTS_FULLNAME"];
                        newRow["OWNER_NAME"]                    = rs["OWNER_NAME"];
                        newRow["MEASURE_SHORTNAME"]             = rs["MEASURE_SHORTNAME"];
                        newRow["WAYBITMS_QUANTITY"]             = rs["WAYBITMS_QUANTITY"];
                        newRow["WAYBITMS_BASEPRICE"]            = rs["WAYBITMS_BASEPRICE"];
                        newRow["WAYBITMS_PERCENT"]              = rs["WAYBITMS_PERCENT"];
                        newRow["WAYBITMS_DOUBLEPERCENT"]        = rs["WAYBITMS_DOUBLEPERCENT"];
                        newRow["WAYBITMS_TOTALPRICEWITHOUTNDS"] = rs["WAYBITMS_TOTALPRICEWITHOUTNDS"];
                        newRow["WAYBITMS_NDS"]                  = rs["WAYBITMS_NDS"];
                        newRow["WAYBITMS_STRNDS"]               = rs["WAYBITMS_STRNDS"];
                        newRow["WAYBITMS_NDSTOTALPRICE"]        = rs["WAYBITMS_NDSTOTALPRICE"];
                        newRow["WAYBITMS_TOTALPRICE"]           = rs["WAYBITMS_TOTALPRICE"];
                        newRow["WAYBITMS_WEIGHT"]               = rs["WAYBITMS_WEIGHT"];
                        newRow["WAYBITMS_PLACES"]               = rs["WAYBITMS_PLACES"];
                        newRow["WAYBITMS_INTPLACES"]            = rs["WAYBITMS_INTPLACES"];
                        newRow["WAYBITMS_TARA"]                 = rs["WAYBITMS_TARA"];
                        newRow["WAYBITMS_QTYINPLACE"]           = rs["WAYBITMS_QTYINPLACE"];
                        newRow["PARTS_CERTIFICATE"]             = rs["PARTS_CERTIFICATE"];
                        newRow["WAYBITMS_NOTES"]                = rs["WAYBITMS_NOTES"];
                        newRow["WAYBITMS_PRICEWITHOUTNDS"]      = rs["WAYBITMS_PRICEWITHOUTNDS"];
                        newRow["COUNTRY_NAME"]                  = rs["COUNTRY_NAME"];
                        newRow["Parts_Guid"]                    = rs["Parts_Guid"];
                        newRow["Parts_Barcode"]                 = rs["Parts_Barcode"];
                        newRow["Parts_BarcodeList"]             = rs["Parts_BarcodeList"];

                        dtReturn.Rows.Add(newRow);
                    }

                    dtReturn.AcceptChanges();
                }
                rs.Dispose();
                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += (String.Format("\nНе удалось получить таблицу с приложением к накладной на внутренее перемещение.\nТекст ошибки: {0}", f.Message));
            }
            return(dtReturn);
        }
Пример #10
0
        /// <summary>
        /// Возвращает список типов цен
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список типов цен</returns>
        public static List <CPriceType> GetPriceTypeList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CPriceType> objList = new List <CPriceType>();

            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_GetPartsubtypePriceType]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                        objList.Add(new CPriceType(
                                        (System.Guid)rs["PartsubtypePriceType_Guid"],
                                        (System.String)rs["PartsubtypePriceType_Name"],
                                        (System.String)rs["PartsubtypePriceType_Abbr"],
                                        ((rs["PartsubtypePriceType_Description"] == System.DBNull.Value) ? "" : (System.String)rs["PartsubtypePriceType_Description"]),
                                        System.Convert.ToBoolean(rs["PartsubtypePriceType_IsActive"]),
                                        new CCurrency(
                                            (System.Guid)rs["Currency_Guid"],
                                            (System.String)rs["Currency_Name"],
                                            (System.String)rs["Currency_Abbr"],
                                            (System.String)rs["Currency_Code"]
                                            ),
                                        System.Convert.ToInt32(rs["PartsubtypePriceType_ColumnIdDefault"]),
                                        System.Convert.ToBoolean(rs["PartsubtypePriceType_ShowInPriceList"])
                                        ));
                    }
                }
                rs.Dispose();

                List <CCurrency> objCurrencyList = CCurrency.GetCurrencyList(objProfile, cmd);
                if ((objList != null) && (objCurrencyList != null))
                {
                    foreach (CPriceType objSPriceType in objList)
                    {
                        objSPriceType.m_objAllCurrencyList = objCurrencyList;
                    }
                }
                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);
        }
Пример #11
0
        /// <summary>
        /// Возвращает таблицу с накладными за указанный период
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="IntWaybill_Guid">УИ документа</param>
        /// <param name="IntWaybill_DateBegin">начало периода для выборки</param>
        /// <param name="IntWaybill_DateEnd">конец периода для выборки</param>
        /// <param name="IntWaybill_SrcCompanyGuid">УИ компании "Откуда"</param>
        /// <param name="IntWaybill_SrcStockGuid">УИ склада "Откуда"<</param>
        /// <param name="IntWaybill_DstCompanyGuid">УИ компании "Куда"</param>
        /// <param name="IntWaybill_DstStockGuid">УИ склада "Куда"<</param>
        /// <param name="Waybill_PaymentTypeGuid">УИ формы оплаты</param>
        /// <param name="strErr">текст ошибки</param>
        /// <param name="SelectIntWaybillInfoFromIntOrder">признак "информация для накладной запрашивается из заказа"</param>
        /// <param name="OnlyUnShippedWaybills">признак "запрос только НЕ отгруженных накладных"</param>
        /// <returns>таблицу</returns>
        public static System.Data.DataTable GetWaybillTable(UniXP.Common.CProfile objProfile,
                                                            System.Data.SqlClient.SqlCommand cmdSQL, System.Guid IntWaybill_Guid,
                                                            System.DateTime IntWaybill_DateBegin, System.DateTime IntWaybill_DateEnd,
                                                            System.Guid IntWaybill_SrcCompanyGuid, System.Guid IntWaybill_SrcStockGuid,
                                                            System.Guid IntWaybill_DstCompanyGuid, System.Guid IntWaybill_DstStockGuid,
                                                            System.Guid Waybill_PaymentTypeGuid, ref System.String strErr,
                                                            System.Boolean SelectIntWaybillInfoFromIntOrder = false,
                                                            System.Boolean OnlyUnShippedWaybills            = false
                                                            )
        {
            System.Data.DataTable dtReturn = new System.Data.DataTable();


            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntOrder_Guid", typeof(System.Guid)));

            dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_Name", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_IsActive", typeof(System.Boolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_IsTrade", typeof(System.Boolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcWarehouse_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcWarehouseType_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Acronym", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Name", typeof(System.String)));

            dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_Name", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_IsActive", typeof(System.Boolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_IsTrade", typeof(System.Boolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstWarehouse_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstWarehouseType_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Acronym", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Name", typeof(System.String)));

            dtReturn.Columns.Add(new System.Data.DataColumn("Currency_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Currency_Abbr", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Depart_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("Depart_Code", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PaymentType_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("PaymentType_Name", typeof(System.String)));

            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillShipMode_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillShipMode_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillShipMode_Name", typeof(System.String)));

            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillState_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillState_Id", typeof(System.Int32)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillState_Name", typeof(System.String)));

            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Num", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("RetailWaybill_Num", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_BeginDate", typeof(System.DateTime)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillParent_Guid", typeof(System.Guid)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_ShipDate", typeof(System.DateTime)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Description", typeof(System.String)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_CurrencyRate", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_AllPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_RetailAllPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_AllDiscount", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_TotalPrice", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Quantity", typeof(System.Double)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_ForStock", typeof(System.Boolean)));
            dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Send", typeof(System.Boolean)));

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;

            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("Не удалось получить соединение с базой данных.");
                        return(dtReturn);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                if (IntWaybill_Guid.CompareTo(System.Guid.Empty) == 0)
                {
                    cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybillList]", objProfile.GetOptionsDllDBName());
                    cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DateBegin", System.Data.DbType.Date));
                    cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DateEnd", System.Data.DbType.Date));
                    cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@OnlyUnShippedWaybills", System.Data.DbType.Guid));
                    cmd.Parameters["@IntWaybill_DateBegin"].Value  = IntWaybill_DateBegin;
                    cmd.Parameters["@IntWaybill_DateEnd"].Value    = IntWaybill_DateEnd;
                    cmd.Parameters["@OnlyUnShippedWaybills"].Value = OnlyUnShippedWaybills;

                    if (IntWaybill_SrcCompanyGuid.CompareTo(System.Guid.Empty) != 0)
                    {
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_SrcCompanyGuid", System.Data.DbType.Guid));
                        cmd.Parameters["@IntWaybill_SrcCompanyGuid"].Value = IntWaybill_SrcCompanyGuid;
                    }
                    if (IntWaybill_SrcStockGuid.CompareTo(System.Guid.Empty) != 0)
                    {
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_SrcStockGuid", System.Data.DbType.Guid));
                        cmd.Parameters["@IntWaybill_SrcStockGuid"].Value = IntWaybill_SrcStockGuid;
                    }

                    if (IntWaybill_DstCompanyGuid.CompareTo(System.Guid.Empty) != 0)
                    {
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DstCompanyGuid", System.Data.DbType.Guid));
                        cmd.Parameters["@IntWaybill_DstCompanyGuid"].Value = IntWaybill_DstCompanyGuid;
                    }
                    if (IntWaybill_DstStockGuid.CompareTo(System.Guid.Empty) != 0)
                    {
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DstStockGuid", System.Data.DbType.Guid));
                        cmd.Parameters["@IntWaybill_DstStockGuid"].Value = IntWaybill_DstStockGuid;
                    }

                    if (Waybill_PaymentTypeGuid.CompareTo(System.Guid.Empty) != 0)
                    {
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Waybill_PaymentTypeGuid", System.Data.DbType.Guid));
                        cmd.Parameters["@Waybill_PaymentTypeGuid"].Value = Waybill_PaymentTypeGuid;
                    }
                }
                else
                {
                    if (SelectIntWaybillInfoFromIntOrder == true)
                    {
                        cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybillFromIntOrder]", objProfile.GetOptionsDllDBName());
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntOrder_Guid", System.Data.DbType.Guid));
                        cmd.Parameters["@IntOrder_Guid"].Value = IntWaybill_Guid;
                    }
                    else
                    {
                        cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybill]", objProfile.GetOptionsDllDBName());
                        cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_Guid", System.Data.DbType.Guid));
                        cmd.Parameters["@IntWaybill_Guid"].Value = IntWaybill_Guid;
                    }
                }
                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("@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)
                {
                    Direction = System.Data.ParameterDirection.Output
                });


                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                System.Int32 iRecordCount = 0;
                if (rs.HasRows)
                {
                    System.Data.DataRow newRow = null;
                    while (rs.Read())
                    {
                        iRecordCount++;

                        newRow = dtReturn.NewRow();
                        newRow["IntWaybill_Guid"]       = ((rs["IntWaybill_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntWaybill_Guid"] : System.Guid.Empty);
                        newRow["IntWaybillParent_Guid"] = ((rs["IntWaybillParent_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntWaybillParent_Guid"] : System.Guid.Empty);
                        newRow["IntOrder_Guid"]         = ((rs["IntOrder_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntOrder_Guid"] : System.Guid.Empty);
                        newRow["IntWaybill_Id"]         = ((rs["IntWaybill_Id"] != System.DBNull.Value) ? (System.Int32)rs["IntWaybill_Id"] : 0);

                        newRow["SrcStock_Guid"]     = ((rs["SrcStock_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcStock_Guid"] : System.Guid.Empty);
                        newRow["SrcStock_Id"]       = ((rs["SrcStock_Id"] != System.DBNull.Value) ? (System.Int32)rs["SrcStock_Id"] : 0);
                        newRow["SrcStock_Name"]     = ((rs["SrcStock_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["SrcStock_Name"]) : System.String.Empty);
                        newRow["SrcStock_IsActive"] = ((rs["SrcStock_IsActive"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["SrcStock_IsActive"]) : false);
                        newRow["SrcStock_IsTrade"]  = ((rs["SrcStock_IsTrade"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["SrcStock_IsTrade"]) : false);

                        newRow["SrcCompany_Guid"]       = ((rs["SrcCompany_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcCompany_Guid"] : System.Guid.Empty);
                        newRow["SrcCompany_Id"]         = ((rs["SrcCompany_Id"] != System.DBNull.Value) ? (System.Int32)rs["SrcCompany_Id"] : 0);
                        newRow["SrcCompany_Acronym"]    = ((rs["SrcCompany_Acronym"] != System.DBNull.Value) ? System.Convert.ToString(rs["SrcCompany_Acronym"]) : System.String.Empty);
                        newRow["SrcCompany_Name"]       = ((rs["SrcCompany_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["SrcCompany_Name"]) : System.String.Empty);
                        newRow["SrcWarehouse_Guid"]     = ((rs["SrcWarehouse_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcWarehouse_Guid"] : System.Guid.Empty);
                        newRow["SrcWarehouseType_Guid"] = ((rs["SrcWarehouseType_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcWarehouseType_Guid"] : System.Guid.Empty);


                        newRow["DstStock_Guid"]         = ((rs["DstStock_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstStock_Guid"] : System.Guid.Empty);
                        newRow["DstStock_Id"]           = ((rs["DstStock_Id"] != System.DBNull.Value) ? (System.Int32)rs["DstStock_Id"] : 0);
                        newRow["DstStock_Name"]         = ((rs["DstStock_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["DstStock_Name"]) : System.String.Empty);
                        newRow["DstStock_IsActive"]     = ((rs["DstStock_IsActive"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["DstStock_IsActive"]) : false);
                        newRow["DstStock_IsTrade"]      = ((rs["DstStock_IsTrade"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["DstStock_IsTrade"]) : false);
                        newRow["DstWarehouse_Guid"]     = ((rs["DstWarehouse_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstWarehouse_Guid"] : System.Guid.Empty);
                        newRow["DstWarehouseType_Guid"] = ((rs["DstWarehouseType_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstWarehouseType_Guid"] : System.Guid.Empty);

                        newRow["DstCompany_Guid"]    = ((rs["DstCompany_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstCompany_Guid"] : System.Guid.Empty);
                        newRow["DstCompany_Id"]      = ((rs["DstCompany_Id"] != System.DBNull.Value) ? (System.Int32)rs["DstCompany_Id"] : 0);
                        newRow["DstCompany_Acronym"] = ((rs["DstCompany_Acronym"] != System.DBNull.Value) ? System.Convert.ToString(rs["DstCompany_Acronym"]) : System.String.Empty);
                        newRow["DstCompany_Name"]    = ((rs["DstCompany_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["DstCompany_Name"]) : System.String.Empty);

                        newRow["Depart_Guid"] = ((rs["Depart_Guid"] != System.DBNull.Value) ? (System.Guid)rs["Depart_Guid"] : System.Guid.Empty);
                        newRow["Depart_Code"] = ((rs["Depart_Code"] != System.DBNull.Value) ? System.Convert.ToString(rs["Depart_Code"]) : System.String.Empty);

                        newRow["Currency_Guid"] = ((rs["Currency_Guid"] != System.DBNull.Value) ? (System.Guid)rs["Currency_Guid"] : System.Guid.Empty);
                        newRow["Currency_Abbr"] = ((rs["Currency_Abbr"] != System.DBNull.Value) ? System.Convert.ToString(rs["Currency_Abbr"]) : System.String.Empty);

                        newRow["PaymentType_Guid"] = ((rs["PaymentType_Guid"] != System.DBNull.Value) ? (System.Guid)rs["PaymentType_Guid"] : System.Guid.Empty);
                        newRow["PaymentType_Name"] = ((rs["PaymentType_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["PaymentType_Name"]) : System.String.Empty);

                        newRow["IntWaybillState_Guid"] = rs["IntWaybillState_Guid"];
                        newRow["IntWaybillState_Id"]   = rs["IntWaybillState_Id"];
                        newRow["IntWaybillState_Name"] = rs["IntWaybillState_Name"];

                        newRow["IntWaybillShipMode_Guid"] = rs["IntWaybillShipMode_Guid"];
                        newRow["IntWaybillShipMode_Id"]   = rs["IntWaybillShipMode_Id"];
                        newRow["IntWaybillShipMode_Name"] = rs["IntWaybillShipMode_Name"];

                        newRow["IntWaybill_BeginDate"] = ((rs["IntWaybill_BeginDate"] != System.DBNull.Value) ? rs["IntWaybill_BeginDate"] : System.DBNull.Value);
                        newRow["IntWaybill_ShipDate"]  = ((rs["IntWaybill_ShipDate"] != System.DBNull.Value) ? rs["IntWaybill_ShipDate"] : System.DBNull.Value);

                        newRow["IntWaybill_Num"]    = rs["IntWaybill_Num"];
                        newRow["RetailWaybill_Num"] = rs["RetailWaybill_Num"];

                        newRow["IntWaybill_Description"] = rs["IntWaybill_Description"];

                        newRow["IntWaybill_AllPrice"]       = rs["IntWaybill_AllPrice"];
                        newRow["IntWaybill_RetailAllPrice"] = rs["IntWaybill_RetailAllPrice"];
                        newRow["IntWaybill_AllDiscount"]    = rs["IntWaybill_AllDiscount"];
                        newRow["IntWaybill_Quantity"]       = System.Convert.ToDecimal(rs["IntWaybill_Quantity"]);

                        newRow["IntWaybill_ForStock"] = rs["IntWaybill_ForStock"];
                        newRow["IntWaybill_Send"]     = rs["IntWaybill_Send"];

                        dtReturn.Rows.Add(newRow);
                    }

                    dtReturn.AcceptChanges();
                }
                rs.Dispose();
                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += (String.Format("\nНе удалось получить таблицу с накладными.\nТекст ошибки: {0}", f.Message));
            }
            return(dtReturn);
        }
Пример #12
0
        /// <summary>
        /// Вносит изменения в поле "Сертификат" в справочнике товаров
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="strCertificate">информация о качестве товара</param>
        /// <param name="uuidProductId">уи товара</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - удачное завершение операции; false - ошибка</returns>
        public static System.Boolean UpdateProductCertificate(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                                              System.String strCertificate, System.Guid uuidProductId, ref System.String strErr)
        {
            System.Boolean bRet = false;
            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr = "Не удалось получить соединение с базой данных.";
                        return(bRet);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }

                cmd.Parameters.Clear();
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_EditProductCertificate]", 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("@Parts_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Parts_Certificate", System.Data.SqlDbType.NVarChar, 256));
                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["@Parts_Guid"].Value        = uuidProductId;
                cmd.Parameters["@Parts_Certificate"].Value = strCertificate;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes != 0)
                {
                    strErr = (System.String)cmd.Parameters["@ERROR_MES"].Value;
                }

                if (cmdSQL == null)
                {
                    DBConnection.Close();
                }
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                strErr = f.Message;
            }
            finally
            {
                if (DBConnection != null)
                {
                    DBConnection.Close();
                }
            }
            return(bRet);
        }
Пример #13
0
        /// <summary>
        /// Привязывает список сертификатов к товару в БД
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="objCertificateList">список сертификатов</param>
        /// <param name="ProductId">УИ товара</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - удачное завершение операции; false - ошибка</returns>
        public static System.Boolean AssignCertificateListWithProduct(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                                                      List <CCertificate> objCertificateList, System.Guid ProductId, ref System.String strErr)
        {
            System.Boolean bRet = false;
            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr = "Не удалось получить соединение с базой данных.";
                        return(bRet);
                    }
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }
                System.Data.DataTable addedCategories = new System.Data.DataTable();
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_Guid", typeof(System.Data.SqlTypes.SqlGuid)));
                addedCategories.Columns.Add(new System.Data.DataColumn("CertificateType_Guid", typeof(System.Data.SqlTypes.SqlGuid)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_Num", typeof(System.Data.SqlTypes.SqlString)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_WhoGive", typeof(System.Data.SqlTypes.SqlString)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_BeginDate", typeof(System.Data.SqlTypes.SqlDateTime)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_EndDate", typeof(System.Data.SqlTypes.SqlDateTime)));

                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_NumForWaybill", typeof(System.Data.SqlTypes.SqlString)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_IsActive", typeof(System.Data.SqlTypes.SqlBoolean)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_Description", typeof(System.Data.SqlTypes.SqlString)));

                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_Image", typeof(System.Data.SqlTypes.SqlBinary)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Certificate_ImageFileFullName", typeof(System.Data.SqlTypes.SqlString)));


                addedCategories.Columns.Add(new System.Data.DataColumn("ActionType_Id", typeof(System.Data.SqlTypes.SqlInt32)));

                System.Data.DataRow newRow = null;
                if ((objCertificateList != null) || (objCertificateList.Count > 0))
                {
                    foreach (CCertificate objItem in objCertificateList)
                    {
                        newRow = addedCategories.NewRow();
                        newRow["Certificate_Guid"]      = objItem.ID;
                        newRow["CertificateType_Guid"]  = objItem.CertificateType.ID;
                        newRow["Certificate_Num"]       = objItem.Num;
                        newRow["Certificate_WhoGive"]   = objItem.WhoGive;
                        newRow["Certificate_BeginDate"] = objItem.BeginDate;
                        if ((objItem.EndDate.CompareTo(System.DateTime.MaxValue) == 0) || (objItem.EndDate.CompareTo(System.DateTime.MinValue) == 0))
                        {
                            newRow["Certificate_EndDate"] = System.DBNull.Value;
                        }
                        else
                        {
                            newRow["Certificate_EndDate"] = objItem.EndDate;
                        }

                        newRow["Certificate_NumForWaybill"] = objItem.NumForWaybill;
                        newRow["Certificate_IsActive"]      = objItem.IsActive;
                        newRow["Certificate_Description"]   = objItem.Description;
                        newRow["ActionType_Id"]             = System.Convert.ToInt32(objItem.ActionType);
                        if (objItem.ImageCertificate != null)
                        {
                            newRow["Certificate_Image"] = objItem.ImageCertificate;
                        }
                        newRow["Certificate_ImageFileFullName"] = objItem.ImageCertificateFileName;

                        addedCategories.Rows.Add(newRow);
                    }
                }
                addedCategories.AcceptChanges();

                cmd.Parameters.Clear();
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_AssignCertificateWithPart]", 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("@Parts_Guid", System.Data.SqlDbType.UniqueIdentifier));
                //cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CERTIFICATE_IMAGE", System.Data.SqlDbType.Image));

                cmd.Parameters.AddWithValue("@tCertificate", addedCategories);
                cmd.Parameters["@tCertificate"].SqlDbType = System.Data.SqlDbType.Structured;
                cmd.Parameters["@tCertificate"].TypeName  = "dbo.udt_Certificate";
                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["@Parts_Guid"].Value    = ProductId;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes != 0)
                {
                    strErr = (System.String)cmd.Parameters["@ERROR_MES"].Value;
                }

                if (cmdSQL == null)
                {
                    DBConnection.Close();
                }
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                strErr = f.Message;
            }
            finally
            {
                if (DBConnection != null)
                {
                    DBConnection.Close();
                }
            }
            return(bRet);
        }
Пример #14
0
 /// <summary>
 /// Загружает из БД изображение товара
 /// </summary>
 /// <param name="objProfile">профайл</param>
 /// <param name="uuidCertificateID">УИ сертификата</param>
 /// <param name="arAttach">изображение в виде массива байт</param>
 /// <param name="strCertificateFileName">название файла с изображением</param>
 /// <param name="strErr">сообщение об ошибке</param>
 /// <returns>true - удачное завершение операции; false - ошибка</returns>
 public static System.Boolean LoadImageFromDB(UniXP.Common.CProfile objProfile, System.Guid uuidCertificateID,
                                              ref byte[] arAttach, ref System.String strCertificateFileName,
                                              ref System.String strErr)
 {
     System.Boolean bRet = false;
     //Создаем соединение с базой данных
     System.Data.SqlClient.SqlConnection DBConnection = objProfile.GetDBSource();
     if (DBConnection == null)
     {
         DevExpress.XtraEditors.XtraMessageBox.Show(
             "Не удалось получить соединение с БД.", "Внимание",
             System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
         return(bRet);
     }
     try
     {
         // соединение с БД получено, прописываем команду на выборку данных
         System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand()
         {
             Connection  = DBConnection, CommandType = System.Data.CommandType.StoredProcedure,
             CommandText = System.String.Format("[{0}].[dbo].[usp_GetPartCertificateImage]", 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("@Certificate_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["@Certificate_Guid"].Value = uuidCertificateID;
         System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
         if (rs.HasRows)
         {
             // набор данных непустой
             rs.Read();
             if (rs["Certificate_Image"] != System.DBNull.Value)
             {
                 strCertificateFileName = ((rs["Certificate_ImageFileFullName"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Certificate_ImageFileFullName"]));
                 arAttach = (byte[])rs["Certificate_Image"];
             }
         }
         rs.Close();
         rs.Dispose();
         bRet = true;
     }
     catch (System.Exception f)
     {
         strErr = "Не удалось получить изображение сертификата. Текст ошибки: " + f.Message;
     }
     finally
     {
         DBConnection.Close();
     }
     return(bRet);
 }
Пример #15
0
        /// <summary>
        /// Возвращает список расчетов прогноза продаж
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список расчетов прогноза продаж</returns>
        public static List<CSalePrognosis> GetSalePrognosisList(UniXP.Common.CProfile objProfile,
            System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List<CSalePrognosis> objList = new List<CSalePrognosis>();
            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_GetSalePrognosisListFromERP_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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                         objList.Add(new CSalePrognosis(System.Convert.ToDateTime(rs["REPORTDATE"]),
                                System.Convert.ToInt32(rs["SALEPROGNOSIS_ID"]), System.Convert.ToInt32(rs["MonthID"]),
                                System.Convert.ToInt32(rs["YearID"]), System.Convert.ToString(rs["YearMonth"])));
                    }
                }
                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;
        }
Пример #16
0
        /// <summary>
        /// Отгрузка товара по накладной
        /// </summary>
        /// <param name="objProfile">Профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="IntWaybill_Guid">УИ накладной на отгрузку</param>
        /// <param name="IntWaybill_ShipDate">Дата отгрузки</param>
        /// <param name="SetIntWaybillShipMode_Guid">УИ варианта отгрузки</param>
        /// <param name="IntWaybillState_Guid">УИ текущего состояния накладной</param>
        /// <param name="ERROR_NUM">целочисленный код ошибки</param>
        /// <param name="ERROR_MES">текст ошибки</param>
        /// <returns>0 - накладная отгружена; <>0 - ошибка</returns>
        public static System.Int32 ShippedProductsByIntWaybill(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                                               System.Guid IntWaybill_Guid, System.DateTime IntWaybill_ShipDate,
                                                               System.Guid SetIntWaybillShipMode_Guid,
                                                               ref System.Guid IntWaybillState_Guid, ref System.Int32 ERROR_NUM, ref System.String ERROR_MES)
        {
            System.Int32 iRet = -1;

            if (IntWaybill_Guid.CompareTo(System.Guid.Empty) == 0)
            {
                ERROR_MES += ("\nНе указан идентификатор накладной.");
                return(iRet);
            }

            if (IntWaybill_ShipDate.CompareTo(System.DateTime.MinValue) == 0)
            {
                ERROR_MES += ("\nУкажите, пожалуйста, дату отгрузки.");
                return(iRet);
            }

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        ERROR_MES += ("\nНе удалось получить соединение с базой данных.");
                        return(iRet);
                    }
                    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_ShipProductsByIntWaybill]", 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("@IntWaybill_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_ShipDate", System.Data.SqlDbType.Date));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@SetIntWaybillShipMode_Guid", System.Data.SqlDbType.UniqueIdentifier));

                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybillState_Guid", System.Data.SqlDbType.UniqueIdentifier)
                {
                    Direction = System.Data.ParameterDirection.Output
                });
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8)
                {
                    Direction = System.Data.ParameterDirection.Output
                });
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000)
                {
                    Direction = System.Data.ParameterDirection.Output
                });

                cmd.Parameters["@IntWaybill_Guid"].Value            = IntWaybill_Guid;
                cmd.Parameters["@IntWaybill_ShipDate"].Value        = IntWaybill_ShipDate;
                cmd.Parameters["@SetIntWaybillShipMode_Guid"].Value = SetIntWaybillShipMode_Guid;

                iRet = cmd.ExecuteNonQuery();

                iRet = System.Convert.ToInt32(cmd.Parameters["@ERROR_NUM"].Value);

                if (cmd.Parameters["@ERROR_NUM"].Value != System.DBNull.Value)
                {
                    ERROR_NUM = (System.Convert.ToInt32(cmd.Parameters["@ERROR_NUM"].Value));
                }
                if (cmd.Parameters["@ERROR_MES"].Value != System.DBNull.Value)
                {
                    ERROR_MES += (System.Convert.ToString(cmd.Parameters["@ERROR_MES"].Value));
                }
                if (cmd.Parameters["@IntWaybillState_Guid"].Value != System.DBNull.Value)
                {
                    IntWaybillState_Guid = (System.Guid)cmd.Parameters["@IntWaybillState_Guid"].Value;
                }

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                ERROR_MES += (String.Format("\nНе удалось выполнить отгрузку накладной.\nТекст ошибки: {0}", f.Message));
            }

            return(iRet);
        }
Пример #17
0
        /// <summary>
        /// Возвращает список расчетов
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список расчетов</returns>
        public static List<CCalcOrder> GetCalcOrderList(UniXP.Common.CProfile objProfile, 
            System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List<CCalcOrder> objList = new List<CCalcOrder>();
            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_GetCalcOrderListFromERP_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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CProductTradeMark objProductTradeMark = null;
                    CCalcOrder objCalcOrder = null;

                    while (rs.Read())
                    {
                        objProductTradeMark = new CProductTradeMark();
                        objProductTradeMark.ID_Ib = System.Convert.ToInt32(rs["OWNER_ID"]);
                        objProductTradeMark.Name = (System.String)rs["OWNER_NAME"];
                        objProductTradeMark.ProductVtm = new CProductVtm();
                        objProductTradeMark.ProductVtm.ID_Ib = System.Convert.ToInt32(rs["VTM_ID"]);
                        objProductTradeMark.ProductVtm.Name = (System.String)rs["VTM_NAME"];

                        objCalcOrder = new CCalcOrder();
                        objCalcOrder.m_uuidID = (System.Guid)rs["CALCORDER_GUID"];
                        objCalcOrder.m_strNum = (System.String)rs["CALCORDER_NUM"];
                        objCalcOrder.m_dtCalcOrderDate = System.Convert.ToDateTime(rs["CALCORDER_BEGINDATE"]);
                        objCalcOrder.m_objProductTradeMark = objProductTradeMark;

                        if (rs["SALEPROGNOSIS_ID"] != System.DBNull.Value)
                        {
                            objCalcOrder.m_objSalePrognosis = new CSalePrognosis(System.Convert.ToDateTime(rs["REPORTDATE"]),
                                System.Convert.ToInt32(rs["SALEPROGNOSIS_ID"]), System.Convert.ToInt32(rs["MonthID"]), 
                                System.Convert.ToInt32(rs["YearID"]), System.Convert.ToString(rs["YearMonth"]) );
                        }

                        objList.Add(objCalcOrder);
                    }
                }
                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;
        }
Пример #18
0
        public static List <CConst> GetConstList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CConst> objList = new List <CConst>();

            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_GetConst]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                        objList.Add(new CConst()
                        {
                            ID           = (System.Guid)rs["Const_Guid"],
                            Name         = System.Convert.ToString(rs["Const_Name"]),
                            DataTypeName = System.Convert.ToString(rs["Const_DataTypeName"]),
                            Description  = ((rs["Const_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Const_Description"])),
                            Value        = System.Convert.ToString(rs["Const_Value"]),
                            ConstType    = new CConstType()
                            {
                                ID          = (System.Guid)rs["ConstType_Guid"],
                                Name        = System.Convert.ToString(rs["ConstType_Name"]),
                                Description = ((rs["ConstType_Description"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["ConstType_Description"])),
                                IsActive    = System.Convert.ToBoolean(rs["ConstType_IsActive"])
                            }
                        });
                    }
                }
                rs.Dispose();

                List <CConstType> objConstTypeList = CConstType.GetConstTypeList(objProfile, cmd);

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
                // а это для выпадающих списков
                if (objConstTypeList != null)
                {
                    foreach (CConst objConst in objList)
                    {
                        objConst.m_objAllConstTypeList = objConstTypeList;
                    }
                }
            }
            catch (System.Exception f)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    "Не удалось получить список констант.\n\nТекст ошибки: " + f.Message, "Внимание",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return(objList);
        }
Пример #19
0
        /// <summary>
        /// Удалить запись из БД
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <returns>true - удачное завершение; false - ошибка</returns>
        public System.Boolean Remove(UniXP.Common.CProfile objProfile)
        {
            System.Boolean bRet = false;
            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand cmd = null;
            //System.Data.SqlClient.SqlTransaction DBTransaction = null;
            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(
                        "Не удалось получить соединение с базой данных.", "Внимание",
                        System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return bRet;
                }
                //DBTransaction = DBConnection.BeginTransaction();
                cmd = new System.Data.SqlClient.SqlCommand();
                cmd.Connection = DBConnection;
                //cmd.Transaction = DBTransaction;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_DeleteCalcOrder]", 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 = this.ID;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                bRet = (iRes == 0);


                if (bRet == true)
                {
                    // подтверждаем транзакцию
                    //DBTransaction.Commit();
                }
                else
                {
                    // откатываем транзакцию
                    //DBTransaction.Rollback();
                    DevExpress.XtraEditors.XtraMessageBox.Show("Ошибка удаления расчета заказа.\n\nТекст ошибки: " +
                    (System.String)cmd.Parameters["@ERROR_MES"].Value, "Ошибка",
                        System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                cmd.Dispose();
            }
            catch (System.Exception f)
            {
                //DBTransaction.Rollback();
                DevExpress.XtraEditors.XtraMessageBox.Show(
                "Не удалось удалить расчет заказа.\n\nТекст ошибки: " + f.Message, "Внимание",
                System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                DBConnection.Close();
            }
            return bRet;
        }
Пример #20
0
        /// <summary>
        /// Сохранить изменения в БД
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <returns>true - удачное завершение; false - ошибка</returns>
        public override System.Boolean Update(UniXP.Common.CProfile objProfile)
        {
            System.Boolean bRet = false;
            if (IsAllParametersValid() == false)
            {
                return(bRet);
            }

            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;
            System.String strErr = "";
            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(
                        "Не удалось получить соединение с базой данных.", "Внимание",
                        System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return(bRet);
                }
                DBTransaction   = DBConnection.BeginTransaction();
                cmd             = new System.Data.SqlClient.SqlCommand();
                cmd.Connection  = DBConnection;
                cmd.Transaction = DBTransaction;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_EditNDSRate]", 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("@NDSRate_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NDSRate_Name", System.Data.DbType.String));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NDSRate_IsActive", System.Data.SqlDbType.Bit));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@NDSRate_Value", System.Data.SqlDbType.Money));

                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["@NDSRate_Guid"].Value     = this.ID;
                cmd.Parameters["@NDSRate_Name"].Value     = this.Name;
                cmd.Parameters["@NDSRate_IsActive"].Value = this.IsActive;
                cmd.Parameters["@NDSRate_Value"].Value    = this.RateValue;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes == 0)
                {
                    // подтверждаем транзакцию
                    DBTransaction.Commit();
                }
                else
                {
                    DBTransaction.Rollback();
                    strErr = (cmd.Parameters["@ERROR_MES"].Value == System.DBNull.Value) ? "" : (System.String)cmd.Parameters["@ERROR_MES"].Value;
                    DevExpress.XtraEditors.XtraMessageBox.Show("Ошибка изменения свойств ставки НДС.\n\nТекст ошибки: " + strErr, "Ошибка",
                                                               System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }

                cmd.Dispose();
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                DBTransaction.Rollback();
                DevExpress.XtraEditors.XtraMessageBox.Show(
                    "Не удалось изменить свойства ставки НДС.\n\nТекст ошибки: " + f.Message, "Внимание",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                DBConnection.Close();
            }
            return(bRet);
        }
Пример #21
0
        /// <summary>
        /// Возвращает список настроект
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="SettingNamesListForInitParams">список имён настроек, параметры которых необходимо проинициализировать</param>
        /// <param name="strErr">текст ошибки</param>
        /// <returns>список настроект</returns>
        public static List <CSettingForImportData> GetSettingslist(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                                                   List <System.String> SettingNamesListForInitParams, ref System.String strErr)
        {
            List <CSettingForImportData> objRet = new List <CSettingForImportData>();

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("\nНе удалось получить соединение с базой данных.");
                        return(objRet);
                    }
                    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_GetSettings]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CSettingForImportData objItem = null;
                    while (rs.Read())
                    {
                        objItem              = new CSettingForImportData();
                        objItem.ID           = (System.Guid)rs["Settings_Guid"];
                        objItem.Name         = ((rs["Settings_Name"] == System.DBNull.Value) ? "" : System.Convert.ToString(rs["Settings_Name"]));
                        objItem.UserName     = ((rs["Settings_UserName"] == System.DBNull.Value) ? System.Convert.ToString(rs["Settings_Name"]) : System.Convert.ToString(rs["Settings_UserName"]));
                        objItem.SettingsList = new List <CSettingItemForImportData>();

                        objItem.XMLSettings = new System.Xml.XmlDocument();
                        objItem.XMLSettings.LoadXml(rs.GetSqlXml(2).Value);

                        if (SettingNamesListForInitParams.SingleOrDefault <String>(x => x == objItem.Name) != null)
                        {
                            foreach (System.Xml.XmlNode objNode in objItem.XMLSettings.ChildNodes)
                            {
                                foreach (System.Xml.XmlNode objChildNode in objNode.ChildNodes)
                                {
                                    objItem.SettingsList.Add(new CSettingItemForImportData()
                                    {
                                        TOOLS_ID          = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_ID"].Value),
                                        TOOLS_NAME        = System.Convert.ToString(objChildNode.Attributes["TOOLS_NAME"].Value),
                                        TOOLS_USERNAME    = System.Convert.ToString(objChildNode.Attributes["TOOLS_USERNAME"].Value),
                                        TOOLS_DESCRIPTION = System.Convert.ToString(objChildNode.Attributes["TOOLS_DESCRIPTION"].Value),
                                        TOOLS_VALUE       = System.Convert.ToInt32(objChildNode.Attributes["TOOLS_VALUE"].Value),
                                        TOOLSTYPE_ID      = System.Convert.ToInt32(objChildNode.Attributes["TOOLSTYPE_ID"].Value)
                                    });
                                }
                            }
                        }

                        objRet.Add(objItem);
                    }
                }
                rs.Dispose();

                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += (String.Format("Не удалось получить список настроек.\n\nТекст ошибки: {0}", f.Message));
            }
            return(objRet);
        }
Пример #22
0
        /// <summary>
        /// Возвращает признак того, находится ли клиент в "черном списке" по кредитномулимиту
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="objCustomer">клиент</param>
        /// <returns>true - клиент в "черном списке"; false - клиента НЕТ в "черном списке"</returns>
        public static System.Boolean IsCustomerInBlackList(UniXP.Common.CProfile objProfile,
                                                           System.Data.SqlClient.SqlCommand cmdSQL, CCustomer objCustomer)
        {
            System.Boolean bRet = false;
            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(bRet);
                    }
                    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_GetIsCustomerInBlackList]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Customer_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IsInBlackList", System.Data.SqlDbType.Bit));
                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("@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["@IsInBlackList"].Direction = System.Data.ParameterDirection.Output;
                cmd.Parameters["@Customer_Guid"].Value     = objCustomer.ID;
                cmd.ExecuteNonQuery();
                bRet = System.Convert.ToBoolean(cmd.Parameters["@IsInBlackList"].Value);
                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(bRet);
        }
Пример #23
0
        /// <summary>
        /// Редактирование записи в базе данных
        /// </summary>
        /// <param name="BackWaybillState_Guid">УИ записи</param>
        /// <param name="BackWaybillState_Name">наименование состояния возвратной накладной</param>
        /// <param name="BackWaybillState_Description">примечание</param>
        /// <param name="BackWaybillState_IsActive">признак "запись активна"</param>
        /// <param name="BackWaybillState_IsDefault">признак "использовать по умолчанию"</param>
        /// <param name="BackWaybillState_Id">код вида оплаты</param>
        /// <param name="BackWaybillState_Guid">УИ записи</param>
        /// <param name="objProfile">профайл</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - удачное завершение операции; false - ошибка</returns>
        public static System.Boolean EditObjectInDataBase(System.Guid BackWaybillState_Guid, System.String BackWaybillState_Name,
                                                          System.String BackWaybillState_Description, System.Boolean BackWaybillState_IsActive,
                                                          System.Boolean BackWaybillState_IsDefault, System.Int32 BackWaybillState_Id,
                                                          UniXP.Common.CProfile objProfile, ref System.String strErr)
        {
            System.Boolean bRet = false;

            if (IsAllParametersValid(BackWaybillState_Name, BackWaybillState_Id, ref strErr) == false)
            {
                return(bRet);
            }

            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;

            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    strErr += ("Не удалось получить соединение с базой данных.");
                    return(bRet);
                }
                DBTransaction   = DBConnection.BeginTransaction();
                cmd             = new System.Data.SqlClient.SqlCommand();
                cmd.Connection  = DBConnection;
                cmd.Transaction = DBTransaction;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_EditBackWaybillState]", 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("@BackWaybillState_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BackWaybillState_Name", System.Data.DbType.String));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BackWaybillState_Description", System.Data.DbType.String));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BackWaybillState_IsActive", System.Data.SqlDbType.Bit));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BackWaybillState_IsDefault", System.Data.SqlDbType.Bit));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BackWaybillState_Id", System.Data.SqlDbType.Int));
                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["@BackWaybillState_Guid"].Value        = BackWaybillState_Guid;
                cmd.Parameters["@BackWaybillState_Name"].Value        = BackWaybillState_Name;
                cmd.Parameters["@BackWaybillState_Description"].Value = BackWaybillState_Description;
                cmd.Parameters["@BackWaybillState_IsActive"].Value    = BackWaybillState_IsActive;
                cmd.Parameters["@BackWaybillState_IsDefault"].Value   = BackWaybillState_IsDefault;
                cmd.Parameters["@BackWaybillState_Id"].Value          = BackWaybillState_Id;
                cmd.ExecuteNonQuery();

                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes == 0)
                {
                    // подтверждаем транзакцию
                    DBTransaction.Commit();
                }
                else
                {
                    DBTransaction.Rollback();
                    strErr += ((cmd.Parameters["@ERROR_MES"].Value == System.DBNull.Value) ? "" : (System.String)cmd.Parameters["@ERROR_MES"].Value);
                }

                cmd.Dispose();
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                DBTransaction.Rollback();

                strErr += ("Не удалось внести изменения в объект \"состояние возвратной накладной\". Текст ошибки: " + f.Message);
            }
            finally
            {
                DBConnection.Close();
            }
            return(bRet);
        }
Пример #24
0
        /// <summary>
        /// Сохраняет в БД информацию о кредитных лимитах
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="objCreditLimitList">список кредитных лимитов</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - удачное завершение; false - ошибка</returns>
        public static System.Boolean SaveCreditLimitList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL,
                                                         List <CCreditLimit> objCreditLimitList, CCustomer objCustomer, CCurrency objCurrency, ref System.String strErr)
        {
            System.Boolean bRet = false;
            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;
            try
            {
                if (objCreditLimitList == null)
                {
                    return(bRet);
                }

                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr = "Не удалось получить соединение с базой данных.";
                        return(bRet);
                    }
                    DBTransaction   = DBConnection.BeginTransaction();
                    cmd             = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection  = DBConnection;
                    cmd.Transaction = DBTransaction;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                }
                else
                {
                    cmd = cmdSQL;
                    cmd.Parameters.Clear();
                }
                System.Data.DataTable addedCategories = new System.Data.DataTable();
                addedCategories.Columns.Add(new System.Data.DataColumn("Customer_Guid", typeof(System.Data.SqlTypes.SqlGuid)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Company_Guid", typeof(System.Data.SqlTypes.SqlGuid)));
                addedCategories.Columns.Add(new System.Data.DataColumn("Currency_Guid", typeof(System.Data.SqlTypes.SqlGuid)));
                addedCategories.Columns.Add(new System.Data.DataColumn("CustomerLimit_ApprovedCurrencyValue", typeof(System.Data.SqlTypes.SqlMoney)));
                addedCategories.Columns.Add(new System.Data.DataColumn("CustomerLimit_CurrencyValue", typeof(System.Data.SqlTypes.SqlMoney)));
                addedCategories.Columns.Add(new System.Data.DataColumn("CustomerLimit_ApprovedDays", typeof(float)));
                addedCategories.Columns.Add(new System.Data.DataColumn("CustomerLimit_Days", typeof(float)));

                System.Data.DataRow newRow = null;
                foreach (CCreditLimit objItem in objCreditLimitList)
                {
                    newRow = addedCategories.NewRow();
                    newRow["Customer_Guid"] = objCustomer.ID;
                    newRow["Company_Guid"]  = objItem.Company.ID;
                    newRow["Currency_Guid"] = objCurrency.ID;
                    newRow["CustomerLimit_ApprovedCurrencyValue"] = System.Convert.ToDecimal(objItem.ApprovedCurrencyValue);
                    newRow["CustomerLimit_CurrencyValue"]         = System.Convert.ToDecimal(objItem.CurrencyValue);
                    newRow["CustomerLimit_ApprovedDays"]          = objItem.ApprovedDays;
                    newRow["CustomerLimit_Days"] = objItem.Days;
                    addedCategories.Rows.Add(newRow);
                }
                if (objCreditLimitList.Count > 0)
                {
                    addedCategories.AcceptChanges();
                }

                cmd.Parameters.Clear();
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_AssignCustomerLimit]", 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("@Customer_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Currency_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.AddWithValue("@tCreditLimitList", addedCategories);
                cmd.Parameters["@tCreditLimitList"].SqlDbType = System.Data.SqlDbType.Structured;
                cmd.Parameters["@tCreditLimitList"].TypeName  = "dbo.udt_CreditLimitList";
                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["@Customer_Guid"].Value = objCustomer.ID;
                cmd.Parameters["@Currency_Guid"].Value = objCurrency.ID;
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes != 0)
                {
                    strErr = (System.String)cmd.Parameters["@ERROR_MES"].Value;
                }

                if (cmdSQL == null)
                {
                    if (iRes == 0)
                    {
                        // подтверждаем транзакцию
                        if (DBTransaction != null)
                        {
                            DBTransaction.Commit();

                            // 2010.04.22
                            // временно пишем в ERP
                            cmd.Parameters.Clear();
                            cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_AssignCustomerLimit_ERP]", 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("@Customer_Guid", System.Data.SqlDbType.UniqueIdentifier));
                            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Currency_Guid", System.Data.SqlDbType.UniqueIdentifier));
                            cmd.Parameters.AddWithValue("@tCreditLimitList", addedCategories);
                            cmd.Parameters["@tCreditLimitList"].SqlDbType = System.Data.SqlDbType.Structured;
                            cmd.Parameters["@tCreditLimitList"].TypeName  = "dbo.udt_CreditLimitList";
                            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["@Customer_Guid"].Value = objCustomer.ID;
                            cmd.Parameters["@Currency_Guid"].Value = objCurrency.ID;
                            cmd.ExecuteNonQuery();
                            iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                        }
                    }
                    else
                    {
                        // откатываем транзакцию
                        if (DBTransaction != null)
                        {
                            DBTransaction.Rollback();
                        }
                    }
                    DBConnection.Close();
                }
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                if ((cmdSQL == null) && (DBTransaction != null))
                {
                    DBTransaction.Rollback();
                }
                strErr = f.Message;
            }
            finally
            {
                if (DBConnection != null)
                {
                    DBConnection.Close();
                }
            }
            return(bRet);
        }
Пример #25
0
        /// <summary>
        /// Добавление новой записи с описанием проекта в базу данных
        /// </summary>
        /// <param name="BUDGETPROJECT_GUID">УИ проекта</param>
        /// <param name="BudgetProject_Name">наименование проекта</param>
        /// <param name="BudgetProject_Description">описание</param>
        /// <param name="BudgetProject_Active">признак "запись активна"</param>
        /// <param name="BudgetProject_1C_CODE">код проекта в 1С</param>
        /// <param name="objProfile">профайл</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>true - удачное завершение операции; false - ошибка</returns>
        public static System.Boolean AddNewObjectToDataBase(System.String BudgetProject_Name,
                                                            System.String BudgetProject_Description, System.Boolean BudgetProject_Active, System.Int32 BudgetProject_1C_CODE,
                                                            ref System.Guid BUDGETPROJECT_GUID, UniXP.Common.CProfile objProfile, ref System.String strErr)
        {
            System.Boolean bRet = false;

            if (IsAllParametersValid(BudgetProject_Name, BudgetProject_1C_CODE, ref strErr) == false)
            {
                return(bRet);
            }

            System.Data.SqlClient.SqlConnection  DBConnection  = null;
            System.Data.SqlClient.SqlCommand     cmd           = null;
            System.Data.SqlClient.SqlTransaction DBTransaction = null;

            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    strErr += ("Не удалось получить соединение с базой данных.");
                    return(bRet);
                }
                DBTransaction   = DBConnection.BeginTransaction();
                cmd             = new System.Data.SqlClient.SqlCommand();
                cmd.Connection  = DBConnection;
                cmd.Transaction = DBTransaction;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_AddBudgetProject]", 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("@BUDGETPROJECT_GUID", System.Data.SqlDbType.UniqueIdentifier, 4, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BUDGETPROJECT_NAME", System.Data.DbType.String));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BUDGETPROJECT_DESCRIPTION", System.Data.DbType.String));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BUDGETPROJECT_ACTIVE", System.Data.SqlDbType.Bit));
                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["@BUDGETPROJECT_NAME"].Value   = BudgetProject_Name;
                cmd.Parameters["@BUDGETPROJECT_ACTIVE"].Value = BudgetProject_Active;
                if (BudgetProject_Description == "")
                {
                    cmd.Parameters["@BUDGETPROJECT_DESCRIPTION"].IsNullable = true;
                    cmd.Parameters["@BUDGETPROJECT_DESCRIPTION"].Value      = null;
                }
                else
                {
                    cmd.Parameters["@BUDGETPROJECT_DESCRIPTION"].IsNullable = false;
                    cmd.Parameters["@BUDGETPROJECT_DESCRIPTION"].Value      = BudgetProject_Description;
                }
                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;
                if (iRes == 0)
                {
                    BUDGETPROJECT_GUID = (System.Guid)cmd.Parameters["@BUDGETPROJECT_GUID"].Value;
                    // подтверждаем транзакцию
                    DBTransaction.Commit();
                }
                else
                {
                    DBTransaction.Rollback();
                    strErr += ((cmd.Parameters["@ERROR_MES"].Value == System.DBNull.Value) ? "" : (System.String)cmd.Parameters["@ERROR_MES"].Value);
                }

                cmd.Dispose();
                bRet = (iRes == 0);
            }
            catch (System.Exception f)
            {
                DBTransaction.Rollback();

                strErr += ("Не удалось создать объект 'проект'. Текст ошибки: " + f.Message);
            }
            finally
            {
                DBConnection.Close();
            }
            return(bRet);
        }
Пример #26
0
        /// <summary>
        /// Возвращает список кредитных лимитов для заданного клиента
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="objCustomer">клиент</param>
        /// <returns>список кредитных лимитов</returns>
        public static List <CCreditLimitArjive> GetCreditLimitArjiveList(UniXP.Common.CProfile objProfile,
                                                                         System.Data.SqlClient.SqlCommand cmdSQL, CCustomer objCustomer, System.DateTime BeginDate, System.DateTime EndDate)
        {
            List <CCreditLimitArjive> objList = new List <CCreditLimitArjive>();

            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].[sp_GetCustomerLimitArjiveForCustomer]", objProfile.GetOptionsDllDBName());
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Customer_Guid", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BeginDate", System.Data.SqlDbType.DateTime));
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EndDate", System.Data.SqlDbType.DateTime));
                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("@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["@Customer_Guid"].Value = objCustomer.ID;
                cmd.Parameters["@BeginDate"].Value     = BeginDate;
                cmd.Parameters["@EndDate"].Value       = EndDate;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CCompany  objCompany  = null;
                    CCurrency objCurrency = null;

                    while (rs.Read())
                    {
                        objCurrency = new CCurrency((System.Guid)rs["Currency_Guid"], (System.String)rs["Currency_Name"],
                                                    (System.String)rs["Currency_Abbr"], (System.String)rs["Currency_Code"]);
                        objCompany = new CCompany((System.Guid)rs["Company_Guid"],
                                                  (System.String)rs["Company_Name"], (System.String)rs["Company_Acronym"]);
                        objList.Add(new CCreditLimitArjive(System.Convert.ToDateTime(rs["Record_Updated"]),
                                                           (System.String)rs["Action_TypeName"], (System.String)rs["Record_UserUdpated"],
                                                           (System.Guid)rs["CustomerLimit_Guid"], objCustomer, objCompany, objCurrency,
                                                           System.Convert.ToDouble(rs["CustomerLimit_ApprovedCurrencyValue"]),
                                                           System.Convert.ToDouble(rs["CustomerLimit_CurrencyValue"]),
                                                           System.Convert.ToInt32(rs["CustomerLimit_ApprovedDays"]),
                                                           System.Convert.ToInt32(rs["CustomerLimit_Days"])));
                    }
                }
                rs.Close();
                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);
        }
Пример #27
0
        /// <summary>
        /// Возвращает список объектов "Проект" из базы данных
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <param name="strErr">сообщение об ошибке</param>
        /// <returns>список объектов класса "Проект"</returns>
        public static List <CBudgetProject> GetBudgetProjectList(UniXP.Common.CProfile objProfile,
                                                                 System.Data.SqlClient.SqlCommand cmdSQL, ref System.String strErr)
        {
            List <CBudgetProject> objList = new List <CBudgetProject>();

            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            try
            {
                if (cmdSQL == null)
                {
                    DBConnection = objProfile.GetDBSource();
                    if (DBConnection == null)
                    {
                        strErr += ("\nНе удалось получить соединение с базой данных.");
                        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_GetBudgetProject]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    System.String strDscrpn = "";
                    while (rs.Read())
                    {
                        strDscrpn = (rs["BUDGETPROJECT_DESCRIPTION"] == System.DBNull.Value) ? "" : (System.String)rs["BUDGETPROJECT_DESCRIPTION"];
                        objList.Add(
                            new CBudgetProject()
                        {
                            ID          = (System.Guid)rs["BUDGETPROJECT_GUID"],
                            Name        = System.Convert.ToString(rs["BUDGETPROJECT_NAME"]),
                            Description = strDscrpn,
                            IsActive    = System.Convert.ToBoolean(rs["BUDGETPROJECT_ACTIVE"]),
                            CodeIn1C    = System.Convert.ToInt32(rs["BUDGETPROJECT_1C_CODE"])
                        }
                            );
                    }
                }
                rs.Dispose();
                if (cmdSQL == null)
                {
                    cmd.Dispose();
                    DBConnection.Close();
                }
            }
            catch (System.Exception f)
            {
                strErr += ("\nНе удалось получить список объектов 'проект'. Текст ошибки: " + f.Message);
            }
            return(objList);
        }
Пример #28
0
        /*  public CCompanyType(Guid uuidID, string strName)
         *    : base(uuidID, strName)
         * {
         *
         * }*/


        #region Список объектов
        public static List <CCompanyType> GetCompanyTypeList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CCompanyType> objList = new List <CCompanyType>();

            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_GetCompanyType]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                        objList.Add(new CCompanyType((System.Guid)rs["CustomerStateType_Guid"],
                                                     (System.String)rs["CustomerStateType_Name"],
                                                     (System.String)rs["CustomerStateType_Description"],
                                                     (System.Boolean)rs["CustomerStateType_IsActive"]));
                    }
                }
                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);
        }
Пример #29
0
        /// <summary>
        /// Возвращает список настроек
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <param name="cmdSQL">SQL-команда</param>
        /// <returns>список настроек</returns>
        public static List <CSetting> GetSettingsList(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL)
        {
            List <CSetting> objList = new List <CSetting>();

            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].[sp_GetSettings]", 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("@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;
                System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader();
                if (rs.HasRows)
                {
                    CSetting objSetting = null;
                    System.Xml.XmlDocument docInfoAboutParam = null;
                    CAdvancedParam         objParam          = null;
                    System.Xml.XmlNode     objRootNode       = null;
                    while (rs.Read())
                    {
                        objSetting           = new CSetting();
                        objSetting.ID        = (System.Guid)rs["Settings_Guid"];
                        objSetting.Name      = System.Convert.ToString(rs["Settings_Name"]);
                        objSetting.ParamList = new List <CAdvancedParam>();
                        if (rs["Settings_XML"] != System.DBNull.Value)
                        {
                            docInfoAboutParam = new System.Xml.XmlDocument();
                            docInfoAboutParam.LoadXml(System.Convert.ToString(rs["Settings_XML"]));
                            if ((docInfoAboutParam != null) && (docInfoAboutParam.ChildNodes.Count > 0))
                            {
                                objSetting.xmldocAdvancedParamList = docInfoAboutParam;
                                objRootNode = docInfoAboutParam.ChildNodes[0];
                                //objSetting.Name = objRootNode.Name;

                                foreach (System.Xml.XmlNode objNode in objRootNode.ChildNodes)
                                {
                                    //if (objNode.Name == "CommonParams")
                                    //{
                                    foreach (System.Xml.XmlNode objChildNode in objNode.ChildNodes)
                                    {
                                        //if (objChildNode.Name == "Params")
                                        //{
                                        foreach (System.Xml.XmlAttribute objAttribute in objChildNode.Attributes)
                                        {
                                            objParam           = new CAdvancedParam(System.Guid.Empty, objAttribute.Name, "", new CParamDataType(0, ""));
                                            objParam.GroupName = objNode.Name;
                                            objParam.Value     = objAttribute.Value;
                                            objSetting.ParamList.Add(objParam);
                                        }
                                        //}
                                        //}
                                    }
                                }
                            }
                        }

                        objList.Add(objSetting);
                    }
                }
                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);
        }
Пример #30
0
        /// <summary>
        /// Удалить запись из БД
        /// </summary>
        /// <param name="objProfile">профайл</param>
        /// <returns>true - удачное завершение; false - ошибка</returns>
        public override System.Boolean Remove(UniXP.Common.CProfile objProfile)
        {
            System.Boolean bRet = false;
            System.Data.SqlClient.SqlConnection DBConnection = null;
            System.Data.SqlClient.SqlCommand    cmd          = null;
            System.String strErr = "";
            try
            {
                DBConnection = objProfile.GetDBSource();
                if (DBConnection == null)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(
                        "Не удалось получить соединение с базой данных.", "Внимание",
                        System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return(bRet);
                }
                cmd             = new System.Data.SqlClient.SqlCommand();
                cmd.Connection  = DBConnection;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_DeleteCertificateType]", 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("@CertificateType_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["@CertificateType_Guid"].Value = this.ID;

                cmd.ExecuteNonQuery();
                System.Int32 iRes = (System.Int32)cmd.Parameters["@RETURN_VALUE"].Value;

                if (iRes != 0)
                {
                    strErr = (cmd.Parameters["@ERROR_MES"].Value == System.DBNull.Value) ? "" : (System.String)cmd.Parameters["@ERROR_MES"].Value;
                    DevExpress.XtraEditors.XtraMessageBox.Show("Ошибка удаления записи.\n\nТекст ошибки: " + strErr, "Ошибка",
                                                               System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }

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