Example #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtDiscontNo.Text != "")
     {
         SqlCommand tmp_cnt = new SqlCommand("DECLARE @C int;  SET @C = (SELECT cnt FROM dbo.dcarduse WHERE (code = '" + txtDiscontNo.Text.Trim() + "') AND (lastdate >= CONVERT(DATETIME, '" + DateTime.Now.Year.ToString("D4") + "-" + DateTime.Now.Month.ToString("D2") + "-" + DateTime.Now.Day.ToString("D2") + " 00:00:00', 102)) AND (lastdate <= CONVERT(DATETIME, '" + DateTime.Now.Year.ToString("D4") + "-" + DateTime.Now.Month.ToString("D2") + "-" + DateTime.Now.Day.ToString("D2") + " 23:59:00', 102))); SELECT ISNULL(@C, 0) AS cnt;", db_connection);
         int cnt = (int)tmp_cnt.ExecuteScalar();
         discont = new DiscontInfo(txtDiscontNo.Text, db_connection);
         if ((discont.Id_dcard != 999999999) && (discont.Id_dcard > 0))
         {
             if (MessageBox.Show("Внимение!\n\nДанные по этой карте взяты из локальной базы т.к. основной сервер не доступен!\nЕсли есть возможность принять карту в следующий раз, то лучше это сделать по позже.\n\nИспользовать эти данные?", "Ошибка получения информации о карте", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
             {
                 discont = new DiscontInfo();
             }
         }
         if ((cnt <= prop.DCard_limit) & (discont.BonusType.Trim() != "Z"))
         {
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             MessageBox.Show("Эта карта уже отработала дневной лимит и не может быть использована!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             this.DialogResult = DialogResult.Cancel;
         }
     }
     else
     {
         this.DialogResult = DialogResult.Cancel;
     }
 }
Example #2
0
 private void btnDiscont_Click(object sender, EventArgs e)
 {
     if (CheckState(db_connection))
     {
         frmGetDiscont fGetDiscont = new frmGetDiscont();
         fGetDiscont.db_connection = db_connection;
         fGetDiscont.ShowDialog();
         if (fGetDiscont.DialogResult == DialogResult.OK)
         {
             if (fGetDiscont.discont.Code_dcard != "")
             {
                 lblOrderDiscont.Text = fGetDiscont.discont.Discserv.ToString() + "%";
                 this.discont = fGetDiscont.discont;
             }
             else
             {
                 MessageBox.Show("Дисконтная карта не найдена в базе!", "Скидка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 lblOrderDiscont.Text = "0%";
                 this.discont = null;
             }
         }
         ReCalc();
     }
 }
Example #3
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);
        }
Example #4
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();
        }
Example #5
0
 private void btnDiscontClear_Click(object sender, EventArgs e)
 {
     lblOrderDiscont.Text = "0%";
     this.discont = null;
     ReCalc();
 }
Example #6
0
        private void frmGetDiscont_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != (char)Keys.Return)
            {
                txtDiscontNo.Text += e.KeyChar.ToString();
            }
            else
            {
                discont = new DiscontInfo(txtDiscontNo.Text, db_connection);
                if ((discont.Id_dcard != 999999999) && (discont.Id_dcard > 0))
                {
                    if (MessageBox.Show("Внимение!\n\nДанные по этой карте взяты из локальной базы т.к. основной сервер не доступен!\nЕсли есть возможность принять карту в следующий раз, то лучше это сделать по позже т.к. списание по ней не пройдет.\n\nИспользовать эти данные?", "Ошибка получения информации о карте", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        discont = new DiscontInfo();
                    }
                }
                this.DialogResult = DialogResult.OK;
            }

            e.Handled = true;
        }
Example #7
0
 private void btnOther_Click(object sender, EventArgs e)
 {
     frmOtherDiscont fOtherDiscont = new frmOtherDiscont(db_connection);
     fOtherDiscont.ShowDialog();
     if (fOtherDiscont.DialogResult == DialogResult.OK)
     {
         discont = new DiscontInfo("9999999999999", fOtherDiscont.pers);
         this.DialogResult = DialogResult.OK;
     }
 }