Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string str   = txtselect_number.Text;
            bool   check = false;

            arr = new string[] {};

            int counts = 0;

            arr = str.Trim().Split(' ');
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i].Trim() != "")
                {
                    counts++;
                }
            }
            arr_new = new string[counts];
            counts  = 0;

            string textlabel  = string.Empty;
            string textNlabel = string.Empty;

            for (int j = 0; j < arr.Length; j++)
            {
                if (arr[j].Trim() != "")
                {
                    textlabel       = arr[j];
                    NlabelNotInUnit = dcore.GetNlabelNotInUnit(DataControls.GetSelectedValueComboBoxToString(cmbunit), out count);
                    if (NlabelNotInUnit.Rows.Count > 0)
                    {
                        foreach (DataRow dr in NlabelNotInUnit.Rows)
                        {
                            if (textlabel.Equals(dr["NLABEL"].ToString()))
                            {
                                check       = true;
                                textNlabel += textlabel + " ";
                            }
                        }
                    }

                    arr_new[counts] = textlabel;

                    counts++;
                }
            }
            if (check)
            {
                MessageBox.Show("ฉลากหมายเลข" + textNlabel + "ถูกใช้งานไปแล้ว");
            }
            else if (ConverValuetoInt(txtnumberlaber.Text) != counts && counts != 0)
            {
                MessageBox.Show("กรุณากรอกหมายเลขฉลากให้เท่ากับจำนวนฉลาก");
            }
            else if (txtnummerperlabel.Text == string.Empty)
            {
                MessageBox.Show("กรุณากรอกจำนวนคนต่อฉลาก");
            }
            else if (txtnumberlaber.Text == string.Empty)
            {
                MessageBox.Show("กรุณากรอกจำนวนฉลาก");
            }
            else if (txtselect_number.Text == string.Empty)
            {
                MessageBox.Show("กรุณากรอกหมายเลขฉลาก");
            }

            else
            {
                UpdateNLabel();
                GetData();
                MessageBox.Show("บันทึกข้อมูลสำเร็จ");
            }
            counts = 0;
        }