Ejemplo n.º 1
0
        public static IInputDocument LoadDocument(int docnum, IGlobalValues data)
        {
            var    sql    = new SqlConnection(data.ConnectionString);
            string sqlcmd = @"SELECT DocTypeID FROM " + data.ActiveSchema +
                            ".DocumentHead WHERE  DocumentHead.DocumentID = " + docnum.ToString();
            SqlCommand cmd = new SqlCommand(sqlcmd, sql);
            int        type;

            try
            {
                sql.Open();
                type = (int)cmd.ExecuteScalar();
                sql.Close();
            }
            catch (Exception exception)
            {
                //return null;
                throw new Exception("Ошибка загрузки свойств документа.", exception);
            }
            switch (type)
            {
            case 1:
            case 3:
                return(PlanDocument.LoadDocument(docnum, data.ActiveSchema + ".DocumentHead", data.ActiveSchema + ".DocumentBody", data.ConnectionString));

            case 2:
            case 4:
                return(DeviceDocument.LoadDocument(docnum, data.ActiveSchema + ".DocumentHead", data.ActiveSchema + ".DocumentBody", data.ConnectionString, new List <int>(data.ProductGroups[DEVICES].Keys)));

            default:
                throw new Exception("Неверный тип документа.");
            }
        }
Ejemplo n.º 2
0
        public CreateTender(IGlobalValues data, int parent)
        {
            InitializeComponent();
            Data = data;
            ForecastDocument doc = ForecastDocument.LoadDocument(parent, Data.ActiveSchema + ".ForecastDocumentHead", Data.ActiveSchema + ".ForecastDocumentBody", Data.ConnectionString);

            parentDoc = doc.Head;
        }
Ejemplo n.º 3
0
        public FormInputDoc(IInputDocument document, IGlobalValues data)
        {
            InitializeComponent();
            Document = document;
            Data     = data;

            docInfo.Text = "Документ № " + Document.Head.DocumentNumber.ToString() +
                           "\nДата: " + Document.Head.DocumentDate.ToString("dd.MM.yyyy") +
                           "\nФабрика: " + Data.FactoryList[Document.Head.Factory];
            this.Text = Data.PlanDocType[Document.Head.DocType] + " № " + Document.Head.DocumentNumber.ToString();
        }
Ejemplo n.º 4
0
        public static DataTable SelectAllDocuments(IGlobalValues data, string headtable, string factorytable, DateTime start, DateTime end, string types)
        {
            var    sql   = new SqlConnection(data.ConnectionString);
            var    table = new DataTable();
            string query = "SELECT     dh.DocumentID, dh.DocumentDate, f.FactoryName, dt.DocTypeName, dh.DocTypeID, dh.FactoryID " +
                           " FROM " + headtable + " dh INNER JOIN dbo.DocumentType dt ON dh.DocTypeID = dt.DocTypeID INNER JOIN " +
                           factorytable + " f ON dh.FactoryID = f.FactoryID " +
                           string.Format(" WHERE (dh.DocumentDate>='{0}') AND ((dh.DocumentDate<='{1}'))", start.ToString("yyyyMMdd"), end.ToString("yyyyMMdd")) +
                           (types != string.Empty ? " AND dh.DocTypeID in (" + types + ")" : "") + " ORDER BY dh.DocumentDate, dh.DocTypeID";
            SqlDataAdapter adapter = new SqlDataAdapter(query, sql);

            adapter.Fill(table);
            return(table);
        }
Ejemplo n.º 5
0
        public CreateInputDoc(IGlobalValues data)
        {
            InitializeComponent();

            Data = data;

            cmbDocType.DataSource    = new BindingSource(data.PlanDocType, null);
            cmbDocType.ValueMember   = "Key";
            cmbDocType.DisplayMember = "Value";

            cmbFactory.DataSource    = new BindingSource(data.FactoryList, null);
            cmbFactory.DisplayMember = "Value";
            cmbFactory.ValueMember   = "Key";

            cmbFactory.Enabled = (cmbFactory.Items.Count != 1);
        }
Ejemplo n.º 6
0
        public static IInputDocument CreateDocument(InputDocumentHead head, IGlobalValues data, int parent)
        {
            switch (head.DocType)
            {
            case 1:
            case 3:
                return(PlanDocument.CreateDocument(head, data.ActiveSchema + ".DocumentHead", data.ActiveSchema + ".DocumentBody", data.ConnectionString, parent));

            case 2:
            case 4:
                return(DeviceDocument.CreateDocument(head, data.ActiveSchema + ".DocumentHead", data.ActiveSchema + ".DocumentBody", data.ConnectionString, new List <int>(data.ProductGroups[DEVICES].Keys), parent));

            default:
                throw new Exception("Неверный тип документа.");
            }
        }
Ejemplo n.º 7
0
        public static DataTable SelectAllDocuments(IGlobalValues data, string headtable, string factorytable, string rptable, DateTime start, DateTime end, string types)
        {
            var    sql   = new SqlConnection(data.ConnectionString);
            var    table = new DataTable();
            string query = "SELECT     fdh.DocumentID, fdh.DocumentDate, rp.RPName, f.FactoryName, fdh.ParentDocument, fdt.DocTypeName, fdh.DocTypeID, fdh.RPID, f.FactoryID" +
                           " FROM " + headtable + " fdh INNER JOIN dbo.ForecastDocumentType fdt ON fdh.DocTypeID = fdt.DocTypeID INNER JOIN " +
                           rptable + " rp ON fdh.RPID = rp.RPID INNER JOIN " + factorytable + " f ON rp.FactoryID = f.FactoryID " +
                           string.Format(" WHERE (fdh.DocumentDate>='{0}') AND ((fdh.DocumentDate<='{1}'))", start.ToString("yyyyMMdd"), end.ToString("yyyyMMdd")) +
                           (types != string.Empty ? " AND fdh.DocTypeID in (" + types + ") " : "") +
                           " ORDER BY fdh.DocumentDate, rp.RPID, fdt.DocTypeID";
            SqlDataAdapter adapter = new SqlDataAdapter(query, sql);

            try
            {
                adapter.Fill(table);
            }
            catch (Exception exc)
            {
                throw new Exception("Ошибка загрузки списка документов.\n" + exc.Message, exc);
                //return null;
            }
            return(table);
        }
Ejemplo n.º 8
0
 public FormTender(IForecastDocument document, IGlobalValues data)
 {
     InitializeComponent();
     Data     = data;
     Document = document;
 }
Ejemplo n.º 9
0
 public static ForecastDocument LoadDocument(int docnum, IGlobalValues data)
 {
     return(ForecastDocument.LoadDocument(docnum, data.ActiveSchema + ".ForecastDocumentHead", data.ActiveSchema + ".ForecastDocumentBody", data.ConnectionString));
 }
Ejemplo n.º 10
0
 public static ForecastDocument CreateDocument(ForecastDocumentHead head, IGlobalValues data)
 {
     return(ForecastDocument.CreateDocument(head, data.ActiveSchema + ".ForecastDocumentHead", data.ActiveSchema + ".ForecastDocumentBody", data.ConnectionString));
 }
Ejemplo n.º 11
0
 public ChooseParent(int rp, IGlobalValues data)
 {
     InitializeComponent();
     rpID = rp;
     Data = data;
 }
Ejemplo n.º 12
0
 public static DataTable SelectAllForecastDocuments(IGlobalValues data, DateTime start, DateTime end, string types)
 {
     return(ForecastDocumentBase.SelectAllDocuments(data, "dbo.vForecastDocumentHead", "dbo.vFactory", "dbo.vRP", start, end, types));
 }
Ejemplo n.º 13
0
 public static DataTable SelectForecastDocuments(IGlobalValues data, DateTime start, DateTime end, string types)
 {
     return(ForecastDocumentBase.SelectAllDocuments(data, data.ActiveSchema + ".ForecastDocumentHead", data.ActiveSchema + ".Factory", data.ActiveSchema + ".RP", start, end, types));
 }
Ejemplo n.º 14
0
 public ChooseParentInputDoc(IGlobalValues data)
 {
     InitializeComponent();
     Data = data;
 }
Ejemplo n.º 15
0
 public CreateTender(IGlobalValues data)
 {
     Data = data;
     InitializeComponent();
 }