Beispiel #1
0
        public static List <DocumentProductConnection> GetAllDocumnetProductConnections()
        {
            MySqlCommand cmd = new MySqlCommand("GetAllDocumnetProductConnections", new MySqlConnection(connectionString));

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Connection.Open();

            MySqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            List <DocumentProductConnection> connections = new List <DocumentProductConnection>();

            while (rdr.Read())
            {
                DocumentProductConnection connection = new DocumentProductConnection();

                connection.connectionId = int.Parse(rdr[0].ToString());
                connection.documentName = rdr[1].ToString();
                connection.connectionId = int.Parse(rdr[2].ToString());

                connections.Add(connection);
            }
            rdr.Close();

            return(connections);
        }
Beispiel #2
0
        public static void InsertDocumentProductConnection(DocumentProductConnection connection)
        {
            List <string> propertyesToIgnore = new List <string> {
            };

            MySqlCommand cmdInsertConnection = new MySqlCommand("InsertDocumentProductConnection", new MySqlConnection(connectionString));

            cmdInsertConnection.CommandType = CommandType.StoredProcedure;

            cmdInsertConnection.Parameters.Add(new MySqlParameter(("_id"), connection.connectionId));
            cmdInsertConnection.Parameters.Add(new MySqlParameter(("_document_name"), connection.documentName));
            cmdInsertConnection.Parameters.Add(new MySqlParameter(("_product_id"), connection.productId));
            cmdInsertConnection.Parameters.Add(new MySqlParameter(("_amount"), connection.amount));

            cmdInsertConnection.Connection.Open();
            cmdInsertConnection.ExecuteNonQuery();
            cmdInsertConnection.Connection.Close();
        }
Beispiel #3
0
 public static void InsertDocumentProductConnection(DocumentProductConnection connection)
 {
     TcpClient.sendObject <DocumentProductConnection>(new DBMsg(ManagerType.DocumentManager, "InsertDocumentProductConnection", JsonConvert.SerializeObject(connection)));
 }
Beispiel #4
0
        private void btnCompleteDocument_Click(object sender, EventArgs e)
        {
            Document document = new Document();

            document.name   = tbox_document_name.Text;
            document.date   = dtp_document_date.Value;
            document.remark = rtb_document_remark.Text;
            try
            {
                switch (selectedDocument)
                {
                case DocumentTypes.receipt:
                    //Finish document props
                    document.supplier    = (Partner)cmb_document_option1.SelectedItem;
                    document.transporter = (Partner)cmb_document_option2.SelectedItem;
                    document.type        = DocumentTypes.receipt;

                    //Action for document type
                    documentReceiveAction();
                    break;

                case DocumentTypes.intermediateWarehouse:
                    //Finish document props
                    document.type                 = DocumentTypes.intermediateWarehouse;
                    document.originWarehouse      = (Warehouse)cmb_document_option1.SelectedItem;
                    document.destinationWarehouse = (Warehouse)cmb_document_option2.SelectedItem;

                    //Action for document
                    documentIntermediateWarehouseAction();
                    break;

                case DocumentTypes.writeOff:
                    document.type = DocumentTypes.writeOff;

                    //Action for document
                    documentRemoveitemsAction();
                    break;

                case DocumentTypes.returnToSupplier:
                    //finish document props
                    document.type     = DocumentTypes.returnToSupplier;
                    document.supplier = (Partner)cmb_document_option1.SelectedItem;

                    //Action for document
                    documentRemoveitemsAction();
                    break;

                default:
                    break;
                }
                document.products = documentProducts;

                DocumentClient.insertDocument(document);

                foreach (ProductDisplay product in document.products)
                {
                    DocumentProductConnection connection = new DocumentProductConnection(
                        DocumentConnectionHolder.documentProductConnections.Count == 0 ? 0 : DocumentConnectionHolder.documentProductConnections.Count + 1,
                        product.id, document.name, product.inUnit);

                    DocumentConnectionHolder.documentProductConnections.Add(connection);
                    DocumentClient.InsertDocumentProductConnection(connection);
                }

                clearDocumentsForm();
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to complete document");
            }
        }