Exemplo n.º 1
0
        public OrderInfo(SqlConnection db_connection, string orderno, bool forPrint)
        {
            this.db_connection = db_connection;

            SqlCommand tmp_cmd = new SqlCommand("SELECT [id_order] as [id], [id_order], [id_user_accept], [id_user_operator], [id_user_designer], [id_user_delivery], [id_client], [guid], [del], [name_accept], [name_operator], [name_delivery], [status], [number], [input_date], [expected_date], [output_date], [advanced_payment], [final_payment], [discont_percent], [discont_code], [preview], [comment], [crop], [type], [bonus], [order_price], [ptype], [auto_export], [id_place], [konvert] FROM [order] WHERE [number] = '" + orderno + "'", db_connection);
            SqlDataReader tmp_rdr = tmp_cmd.ExecuteReader();
            if (tmp_rdr.Read())
            {
                /*
                 * 1  [id_order],
                 * 2  [id_user_accept],
                 * 3  [id_user_operator],
                 * 4  [id_user_designer],
                 * 5  [id_user_delivery],
                 * 6!  [id_client],
                 * 7  [guid],
                 * 8  [del],
                 * 9  [name_accept],
                 * 10 [name_operator],
                 * 11 [name_delivery],
                 *! 12 [status],
                 *! 13 [number],
                 *! 14 [input_date],
                 *! 15 [expected_date],
                 * 16 [output_date],
                 *! 17 [advanced_payment],
                 *! 18 [final_payment],
                 *! 19 [discont_percent],
                 *! 20 [discont_code],
                 *! 21 [preview],
                 *! 22 [comment]
                 *! 23 [crop]
                 *! 24 [type]
                 *  25 [bonus]
                 *  26 order_price
                 *  27 ptype
                 */
                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(9))
                    _name_accept = tmp_rdr.GetString(9);
                else
                    _name_accept = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(23))
                    _crop = tmp_rdr.GetInt32(23);
                else
                    _crop = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(24))
                    _type = tmp_rdr.GetInt32(24);
                else
                    _type = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(22))
                    _comment = tmp_rdr.GetString(22);
                else
                    _comment = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(21))
                    if (tmp_rdr.GetBoolean(21))
                        _preview = 1;
                    else
                        _preview = 0;
                else
                    _preview = 0;

                ///////////////////////////////////
                if ((!tmp_rdr.IsDBNull(20)) && (!tmp_rdr.IsDBNull(20)))
                {
                    Discont = new DiscontInfo(tmp_rdr.GetString(20), db_connection);
                    Discont.Id_dcard = 777777777;
                }
                //Discont = new DiscontInfo(tmp_rdr.GetString(20), tmp_rdr.GetDecimal(19));
                else
                    Discont = new DiscontInfo("", 0);

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(18))
                    _finalPayment = tmp_rdr.GetDecimal(18);
                else
                    _finalPayment = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(25))
                    _bonus = tmp_rdr.GetDecimal(25);
                else
                    _bonus = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(26))
                    _order_price = tmp_rdr.GetDecimal(26);
                else
                    _order_price = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(27))
                    _ptype = tmp_rdr.GetInt32(27);
                else
                    _ptype = -1;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(17))
                    _advancedPayment = tmp_rdr.GetDecimal(17);
                else
                    _advancedPayment = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(14))
                    _datein = tmp_rdr.GetDateTime(14).ToShortDateString();
                else
                    _datein = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(14))
                    _timein = tmp_rdr.GetDateTime(14).ToShortTimeString();
                else
                    _timein = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(15))
                    _dateout = tmp_rdr.GetDateTime(15).ToShortDateString();
                else
                    _dateout = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(15))
                    _timeout = tmp_rdr.GetDateTime(15).ToShortTimeString();
                else
                    _timeout = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(13))
                    _orderno = tmp_rdr.GetString(13);
                else
                    _orderno = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(12))
                    _distanation = tmp_rdr.GetString(12);
                else
                    _distanation = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(6))
                    _client_id = tmp_rdr.GetInt32(6);
                else
                    _client_id = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(1))
                    this._id = tmp_rdr.GetInt32(1);
                else
                    this._id = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(28))
                    _autoexport = tmp_rdr.GetInt32(28);
                else
                    _autoexport = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(29))
                    _place = tmp_rdr.GetInt32(29);
                else
                    _place = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(30))
                    _konvert = tmp_rdr.GetInt32(30);
                else
                    _konvert = 0;

            }
            tmp_rdr.Close();
            if (_client_id > 0)
                Client = new ClientInfo(_client_id, db_connection);
            else
                Client = null;
            tmp_cmd.CommandText = "SELECT dbo.orderbody.id_orderbody, dbo.orderbody.id_order, dbo.orderbody.id_good, dbo.orderbody.guid, dbo.orderbody.del, dbo.orderbody.quantity, dbo.orderbody.actual_quantity, dbo.orderbody.sign, dbo.orderbody.price, dbo.good.name, dbo.orderbody.datework, dbo.orderbody.id_user_work, dbo.orderbody.name_work, dbo.orderbody.defect_quantity, dbo.orderbody.id_user_defect, dbo.orderbody.user_defect, dbo.orderbody.tech_defect, dbo.orderbody.name_add, dbo.orderbody.comment FROM dbo.orderbody INNER JOIN dbo.good ON dbo.orderbody.id_good = dbo.good.id_good WHERE (((dbo.orderbody.del <> 1) OR (ISNULL(dbo.orderbody.del, 0) = 0)) AND ([id_order] = " + this.Id + ") AND ((dbo.orderbody.actual_quantity <> 0) OR (dbo.orderbody.quantity <> 0))) ORDER BY dbo.orderbody.id_order, dbo.orderbody.id_orderbody";
            //tmp_rdr = tmp_cmd.ExecuteReader();
            tmp_cmd.CommandTimeout = 9000;
            SqlDataAdapter da = new SqlDataAdapter(tmp_cmd);
            OrderBody = new DataTable("Order");
            da.Fill(OrderBody);
        }
Exemplo n.º 2
0
        private void SelectClient(string id_client, string guid)
        {
            if (CheckState(db_connection))
            {
                if (id_client != "")
                    client = new ClientInfo(int.Parse(id_client), db_connection);
                else
                    client = new ClientInfo(0, guid, db_connection);
                lblName.Text = client.Name;
                lblPhone1.Text = "Телефон: " + client.Phone1;
                lblPhone2.Text = "Доп телефон: " + client.Phone2;
                lblAddress.Text = "Адрес: " + client.Address;
                lblemail.Text = "Эл. почта: " + client.Email;
                lblicq.Text = "ICQ: " + client.Icq;
                lbladdon.Text = "Дополнительно: " + client.Addon;
                lblcategory.Text = "Категория: " + client.Category_name;

                btnNext.Enabled = true;
                /*
                db_command.Connection = db_connection;
                if (guid != "")
                {
                    db_command.CommandText = "SELECT [id_client], [name], [phone_1], [phone_2], [address], [email], [icq], [addon], [categoryname] FROM [PSAv1].[dbo].[vwClientFull] WHERE [guid] = '" + guid + "'";
                }
                if (id_client != "")
                {
                    db_command.CommandText = "SELECT [id_client], [name], [phone_1], [phone_2], [address], [email], [icq], [addon], [categoryname] FROM [PSAv1].[dbo].[vwClientFull] WHERE [id_client] = " + id_client;
                }
                db_reader = db_command.ExecuteReader();
                if (db_reader.Read())
                {
                    if (!db_reader.IsDBNull(1))
                        lblName.Text = db_reader.GetString(1);
                    else
                        lblName.Text = "";
                    if (!db_reader.IsDBNull(2))
                        lblPhone1.Text = "Телефон: " + db_reader.GetString(2);
                    else
                        lblPhone1.Text = "Телефон: -";
                    if (!db_reader.IsDBNull(3))
                        lblPhone2.Text = "Доп телефон: " + db_reader.GetString(3);
                    else
                        lblPhone2.Text = "Телефон: -";
                    if (!db_reader.IsDBNull(4))
                        lblAddress.Text = "Адрес: " + db_reader.GetString(4);
                    else
                        lblAddress.Text = "Адрес: -";
                    if (!db_reader.IsDBNull(5))
                        lblemail.Text = "Эл. почта: " + db_reader.GetString(5);
                    else
                        lblemail.Text = "Эл. почта: -";
                    if (!db_reader.IsDBNull(6))
                        lblicq.Text = "ICQ: " + db_reader.GetString(6);
                    else
                        lblicq.Text = "ICQ: -";
                    if (!db_reader.IsDBNull(7))
                        lbladdon.Text = "Дополнительно: " + db_reader.GetString(7);
                    else
                        lbladdon.Text = "Дополнительно: -";
                    if (!db_reader.IsDBNull(8))
                        lblcategory.Text = "Категория: " + db_reader.GetString(8);
                    else
                        lblcategory.Text = "Категория: ?!";

                    btnNext.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Ошибка получения данных о клиенте!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    btnNext.Enabled = false;
                }
                db_reader.Close();
                */
            }
        }
Exemplo n.º 3
0
        public OrderInfo(SqlConnection db_connection, int id_order)
        {
            this.db_connection = db_connection;
            this._id = id_order;

            SqlCommand tmp_cmd = new SqlCommand("SELECT [id_order] as [id], [id_order], [id_user_accept], [id_user_operator], [id_user_designer], [id_user_delivery], [id_client], [guid], [del], [name_accept], [name_operator], [name_delivery], [status], [number], [input_date], [expected_date], [output_date], [advanced_payment], [final_payment], [discont_percent], [discont_code], [preview], [comment], [crop], [type], [bonus], [order_price], [ptype], [auto_export], [id_place], [konvert] FROM [order] WHERE [id_order] = " + id_order, db_connection);
            SqlDataReader tmp_rdr = tmp_cmd.ExecuteReader();
            if (tmp_rdr.Read())
            {
                /*
                 * 1  [id_order],
                 * 2  [id_user_accept],
                 * 3  [id_user_operator],
                 * 4  [id_user_designer],
                 * 5  [id_user_delivery],
                 * 6!  [id_client],
                 * 7  [guid],
                 * 8  [del],
                 * 9  [name_accept],
                 * 10 [name_operator],
                 * 11 [name_delivery],
                 *! 12 [status],
                 *! 13 [number],
                 *! 14 [input_date],
                 *! 15 [expected_date],
                 * 16 [output_date],
                 *! 17 [advanced_payment],
                 *! 18 [final_payment],
                 *! 19 [discont_percent],
                 *! 20 [discont_code],
                 *! 21 [preview],
                 *! 22 [comment]
                 *! 23 [crop]
                 *! 24 [type]
                 *  25 [bonus]
                 *  26 order_price
                 *  27 ptype
                 */
                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(9))
                    _name_accept = tmp_rdr.GetString(9);
                else
                    _name_accept = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(23))
                    _crop = tmp_rdr.GetInt32(23);
                else
                    _crop = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(24))
                    _type = tmp_rdr.GetInt32(24);
                else
                    _type = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(22))
                    _comment = tmp_rdr.GetString(22);
                else
                    _comment = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(21))
                    if (tmp_rdr.GetBoolean(21))
                        _preview = 1;
                    else
                        _preview = 0;
                else
                    _preview = 0;

                ///////////////////////////////////
                if ((!tmp_rdr.IsDBNull(20)) && (!tmp_rdr.IsDBNull(20)))
                {
                    Discont = new DiscontInfo(tmp_rdr.GetString(20), db_connection);
                    Discont.Id_dcard = 777777777;
                }
                else
                {
                    Discont = new DiscontInfo("", 0);
                }

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(18))
                    _finalPayment = tmp_rdr.GetDecimal(18);
                else
                    _finalPayment = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(25))
                    _bonus = tmp_rdr.GetDecimal(25);
                else
                    _bonus = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(26))
                    _order_price = tmp_rdr.GetDecimal(26);
                else
                    _order_price = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(27))
                    _ptype = tmp_rdr.GetInt32(27);
                else
                    _ptype = -1;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(17))
                    _advancedPayment = tmp_rdr.GetDecimal(17);
                else
                    _advancedPayment = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(14))
                    _datein = tmp_rdr.GetDateTime(14).ToShortDateString();
                else
                    _datein = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(14))
                    _timein = tmp_rdr.GetDateTime(14).ToShortTimeString();
                else
                    _timein = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(15))
                    _dateout = tmp_rdr.GetDateTime(15).ToShortDateString();
                else
                    _dateout = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(15))
                    _timeout = tmp_rdr.GetDateTime(15).ToShortTimeString();
                else
                    _timeout = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(13))
                    _orderno = tmp_rdr.GetString(13);
                else
                    _orderno = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(12))
                    _distanation = tmp_rdr.GetString(12);
                else
                    _distanation = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(6))
                    _client_id = tmp_rdr.GetInt32(6);
                else
                    _client_id = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(1))
                    id_order = tmp_rdr.GetInt32(1);
                else
                    id_order = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(28))
                    _autoexport = tmp_rdr.GetInt32(28);
                else
                    _autoexport = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(29))
                    _place = tmp_rdr.GetInt32(29);
                else
                    _place = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(30))
                    _konvert = tmp_rdr.GetInt32(30);
                else
                    _konvert = 0;

            }
            tmp_rdr.Close();
            if (_client_id > 0)
                Client = new ClientInfo(_client_id, db_connection);
            else
                Client = null;
            tmp_cmd.CommandText = "SELECT dbo.orderbody.id_orderbody, dbo.orderbody.id_order, dbo.orderbody.id_good, dbo.orderbody.guid, dbo.orderbody.del, dbo.orderbody.quantity, dbo.orderbody.actual_quantity, dbo.orderbody.sign, dbo.orderbody.price, dbo.good.name, dbo.orderbody.datework, dbo.orderbody.id_user_work, dbo.orderbody.name_work, dbo.orderbody.defect_quantity, dbo.orderbody.id_user_defect, dbo.orderbody.user_defect, dbo.orderbody.tech_defect, dbo.orderbody.name_add, dbo.orderbody.comment FROM dbo.orderbody INNER JOIN dbo.good ON dbo.orderbody.id_good = dbo.good.id_good WHERE (((dbo.orderbody.del <> 1) OR (ISNULL(dbo.orderbody.del, 0) = 0)) AND ([id_order] = " + this.Id + ") AND ((dbo.orderbody.actual_quantity <> 0) OR (dbo.orderbody.quantity <> 0))) ORDER BY dbo.orderbody.id_order, dbo.orderbody.id_orderbody";
            tmp_cmd.CommandTimeout = 9000;
            tmp_rdr = tmp_cmd.ExecuteReader();

            OrderBody = new DataTable("Order");

            OrderBody.Columns.Add("check", System.Type.GetType("System.Boolean"));			// 0
            OrderBody.Columns.Add("Name", System.Type.GetType("System.String"));			// 1
            OrderBody.Columns.Add("GoodId", System.Type.GetType("System.String"));			// 2
            OrderBody.Columns.Add("Count", System.Type.GetType("System.Decimal"));			// 3
            OrderBody.Columns.Add("ActualCount", System.Type.GetType("System.Decimal"));	// 4
            OrderBody.Columns.Add("Price", System.Type.GetType("System.Decimal"));			// 5
            OrderBody.Columns.Add("Sum", System.Type.GetType("System.Decimal"));			// 6
            OrderBody.Columns.Add("ActualSum", System.Type.GetType("System.Decimal"));		// 7
            OrderBody.Columns.Add("Sign", System.Type.GetType("System.String"));			// 8
            OrderBody.Columns.Add("old", System.Type.GetType("System.Boolean"));			// 9
            OrderBody.Columns.Add("guid", System.Type.GetType("System.String"));			// 10
            OrderBody.Columns.Add("datework", System.Type.GetType("System.String"));		// 11 10
            OrderBody.Columns.Add("id_user_work", System.Type.GetType("System.Int32"));		// 12 11
            OrderBody.Columns.Add("name_work", System.Type.GetType("System.String"));		// 13 12
            OrderBody.Columns.Add("defect_quantity", System.Type.GetType("System.Decimal"));// 14 13
            OrderBody.Columns.Add("id_user_defect", System.Type.GetType("System.Int32"));	// 15 14
            OrderBody.Columns.Add("user_defect", System.Type.GetType("System.String"));		// 16 15
            OrderBody.Columns.Add("tech_defect", System.Type.GetType("System.Int32"));		// 17 16
            OrderBody.Columns.Add("name_add", System.Type.GetType("System.String"));		// 18 17
            OrderBody.Columns.Add("comment", System.Type.GetType("System.String"));		    // 19 18

            /*
             * 0  [id_orderbody],
             * 1  [id_order],
             * 2  [id_good],
             * 3  [guid],
             * 4  [del],
             * 5  [quantity],
             * 6  [actual_quantity],
             * 7  [sign],
             * 8  [price]
             * 9  [name]
             * 10 datework,
             * 11 id_user_work,
             * 12 name_work,
             * 13 defect_quantity,
             * 14 id_user_defect,
             * 15 user_defect,
             * 16 tech_defect
             */

            while (tmp_rdr.Read())
            {
                object[] r = new object[20];
                r[0] = false;
                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(9))
                    r[1] = tmp_rdr.GetString(9);
                else
                    r[1] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(2))
                    r[2] = tmp_rdr.GetString(2);
                else
                    r[2] = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(5))
                    r[3] = tmp_rdr.GetDecimal(5);
                else
                    r[3] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(6))
                    r[4] = tmp_rdr.GetDecimal(6);
                else
                    r[4] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(8))
                    r[5] = tmp_rdr.GetDecimal(8);
                else
                    r[5] = 0;

                ///////////////////////////////////
                r[6] = (decimal)r[3] * (decimal)r[5];

                ///////////////////////////////////
                r[7] = (decimal)r[4] * (decimal)r[5];

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(7))
                    r[8] = tmp_rdr.GetString(7);
                else
                    r[8] = 0;

                ///////////////////////////////////
                r[9] = true;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(3))
                    r[10] = tmp_rdr.GetString(3);
                else
                    r[10] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(10))
                    r[11] = tmp_rdr.GetDateTime(10);
                else
                    r[11] = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(11))
                    r[12] = tmp_rdr.GetInt32(11);
                else
                    r[12] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(12))
                    r[13] = tmp_rdr.GetString(12);
                else
                    r[13] = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(13))
                    r[14] = tmp_rdr.GetDecimal(13);
                else
                    r[14] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(14))
                    r[15] = tmp_rdr.GetInt32(14);
                else
                    r[15] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(15))
                    r[16] = tmp_rdr.GetString(15);
                else
                    r[16] = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(16))
                    r[17] = tmp_rdr.GetInt32(16);
                else
                    r[17] = 0;

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(17))
                    r[18] = tmp_rdr.GetString(17).Trim();
                else
                    r[18] = "";

                ///////////////////////////////////
                if (!tmp_rdr.IsDBNull(18))
                    r[19] = tmp_rdr.GetString(18).Trim();
                else
                    r[19] = "";

                OrderBody.Rows.Add(r);

            }
            tmp_rdr.Close();
        }
Exemplo n.º 4
0
 private void SelectClient(string id)
 {
     client = new ClientInfo(int.Parse(id), db_connection);
     this.DialogResult = DialogResult.OK;
 }