예제 #1
0
        private void dgvpart_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1) { return; }

            // txtcustomerpart.Text = Convert.ToString(dgvpart.Rows[e.RowIndex].Cells["CustomerPart"].Value.ToString());
            txtmodel.Text = Convert.ToString(dgvpart.Rows[e.RowIndex].Cells["Model"].Value.ToString());
            var parts = Session.CreateQuery("from Part p where p.Id =" + dgvpart.Rows[e.RowIndex].Cells["Id"].Value.ToString()).Future<Part>();
            part = parts.First();

            string _serial = "";
            var _labels = Session.CreateQuery("from Label p where p.PartName =" + dgvpart.Rows[e.RowIndex].Cells["Ckt"].Value.ToString()).Future<plabel2.Entities.Label>();
            if (_labels.Count() > 0)
            {
                List<plabel2.Entities.Label> labels = _labels.ToList();
                foreach (plabel2.Entities.Label ln in labels)
                {
                    txtpartname.Text = ln.Ckt;
                    txtserial.Text = ln.SerialNo;
                    txtckt.Text = ln.Ckt;
                    txtmodel.Text = ln.Model;
                    txtoiltype.Text = ln.OilType;
                    txtoilweitht.Text = ln.OilWeight;
                    txtline.Text = ln.Line;
                    txtprintdate.Text = String.Format("{0:dd/MM/yyyy}", ln.PrintTime);

                    this.pictureEdit1.Image = Image.FromFile(@"D:\pic4\"+part.LabelType.Picture+".bmp");

                }
            }
        }
예제 #2
0
        private void cmdadd_Click(object sender, EventArgs e)
        {
            if (cmdadd.Text == "Add")
            {
                txtcuspart.Text = "";
                txtckt.Text = "";
                txtmodel.Text = "";
                txtoiltype.Text = "";
                txtoilweight.Text = "";

                txtcuspart.Enabled = true;
                txtckt.Enabled = true;
                txtmodel.Enabled = true;
                txtoiltype.Enabled = true;
                txtoilweight.Enabled = true;
                rdb1.Enabled = true;
                rdb2.Enabled = true;

                rdb1.Checked = false;
                rdb2.Checked = false;

                cmdadd.Text = "Save";
            }
            else if (cmdadd.Text == "Save")
            {
                if (txtcuspart.Text.Trim() == "")
                {
                    XtraMessageBox.Show("กรุณากรอก Customer Part ก่อน  !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtcuspart.Focus();
                    return;
                }
                if (txtckt.Text.Trim() == "")
                {
                    XtraMessageBox.Show("กรุณากรอก CKT ก่อน  !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtckt.Focus();
                    return;
                }
                if (txtmodel.Text.Trim() == "")
                {
                    XtraMessageBox.Show("กรุณากรอก Model ก่อน  !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtmodel.Focus();
                    return;
                }
                if (txtoiltype.Text.Trim() == "")
                {
                    XtraMessageBox.Show("กรุณากรอก Oiltype ก่อน  !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtoiltype.Focus();
                    return;
                }
                if (txtoilweight.Text.Trim() == "")
                {
                    XtraMessageBox.Show("กรุณากรอก Oilweight ก่อน  !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtoilweight.Focus();
                    return;
                }

                if (rdb1.Checked == false && rdb2.Checked == false)
                {
                    XtraMessageBox.Show("กรุณาเลือก Type Of Label  ก่อน  !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    rdb1.Focus();
                    return;
                }

                newPart = new Part();
                newPart.CustomerPart = txtcuspart.Text.Trim();
                newPart.Ckt = txtckt.Text.Trim();
                newPart.Model = txtmodel.Text.Trim();
                newPart.OilType = txtoiltype.Text.Trim();
                newPart.OilWeight = txtoilweight.Text.Trim();

                LabelType _labelType = new LabelType();

                if (rdb1.Checked == true)
                {
                    var lTypes = Session.CreateQuery("from LabelType p where p.Id =300").Future<LabelType>();
                    _labelType = lTypes.First();
                }
                else if (rdb2.Checked == true)
                {
                    var lTypes = Session.CreateQuery("from LabelType p where p.Id =500").Future<LabelType>();
                    _labelType = lTypes.First();
                }
                newPart.LabelType = _labelType;

                string _dtDate = dateTimePicker1.Value.ToShortDateString();

                string[] _days = Regex.Split(_dtDate, "/");
                int year = Convert.ToInt32(_days[2]) - 543;
                int mount = Convert.ToInt32(_days[0]);
                int day = Convert.ToInt32(_days[1]);
                string txtdate = day.ToString("00") + "/" + mount.ToString("00") + "/" + year.ToString("0000");

                newPart.DateAdd = dateTimePicker1.Value;
                using (ITransaction tx = Session.BeginTransaction())
                {
                    Session.Save(newPart);
                    Session.Flush();
                    tx.Commit();
                }
                // Session.Dispose();
                ShowData();
                cleartxt();

            }
        }
예제 #3
0
        private void dgvpart_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1) { return; }

            txtcustomerpart.Text = Convert.ToString(dgvpart.Rows[e.RowIndex].Cells["CustomerPart"].Value.ToString());
            txtmodel.Text = Convert.ToString(dgvpart.Rows[e.RowIndex].Cells["Model"].Value.ToString());
            var parts = Session.CreateQuery("from Part p where p.Id =" + dgvpart.Rows[e.RowIndex].Cells["Id"].Value.ToString()).Future<Part>();
            part = parts.First();

            string partid =  dgvpart.Rows[e.RowIndex].Cells["Id"].Value.ToString();
            var snps = Session.CreateQuery("from SnpOrder where PartId='"+partid+"'").Future<SnpOrder>();

            if (snps.Count() > 0)
            {
                snpOrder = snps.First();
                txtsn.Text = snpOrder.Snp;
                lblprint.Text = snpOrder.QtyComplete+"/"+snpOrder.Snp;
            }
            else
            {
                snpOrder = new SnpOrder();
            }
            if (dateTimePicker1.Value.Equals(dateTimePicker2.Value))
            {
                txtsn.Enabled = false;
            }
            else {
                txtsn.Enabled = true;
            }
        }
예제 #4
0
        private void dgvpart_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1) { return; }

            var parts = Session.CreateQuery("from Part p where p.Id =" + dgvpart.Rows[e.RowIndex].Cells["Id"].Value.ToString()).Future<Part>();
            EditPart = parts.First();

            txtcuspart.Text = EditPart.CustomerPart;
            txtckt.Text = EditPart.Ckt;
            txtmodel.Text = EditPart.Model;
            txtoiltype.Text = EditPart.OilType;
            txtoilweight.Text = EditPart.OilWeight;

            if (EditPart.LabelType.Id == 300)
            {
                rdb1.Checked = true;
                rdb2.Checked = false;
            }
            else
            {
                rdb1.Checked = false;
                rdb2.Checked = true;
            }
            rdb1.Enabled = false;
            rdb2.Enabled = false;

            enabelObj(false);
            cmdadd.Text = "Add";
            cmdedit.Text = "Edit";
        }
예제 #5
0
        private void dgvpart_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1) { return; }

               // txtcustomerpart.Text = Convert.ToString(dgvpart.Rows[e.RowIndex].Cells["CustomerPart"].Value.ToString());
            txtmodel.Text = Convert.ToString(dgvpart.Rows[e.RowIndex].Cells["Model"].Value.ToString());
            var parts = Session.CreateQuery("from Part p where p.Id =" + dgvpart.Rows[e.RowIndex].Cells["Id"].Value.ToString()).Future<Part>();
            part = parts.First();

            string _dtDate = dateTimePicker2.Value.ToShortDateString();

            string[] _days = Regex.Split(_dtDate, "/");
            int year = Convert.ToInt32(_days[2]) - 543;
            int mount = Convert.ToInt32(_days[0]);

            string _serial = "";
            var _labels = Session.CreateQuery("from Label p where p.PartName =" + dgvpart.Rows[e.RowIndex].Cells["Ckt"].Value.ToString()).Future<plabel2.Entities.Label>();

            if (_labels.ToList().Count > 0)
            {
                List<plabel2.Entities.Label> labels = _labels.ToList();
                foreach (plabel2.Entities.Label ln in labels)
                {
                    run = Convert.ToInt32(ln.Run + 1);
                    _serial = ln.SerialNo;
                    line = ln.Line;
                }

                string tmp = StrLeft(_serial, 4);
                string snmonth = StrRight(tmp, 2);

                if (snmonth != mount.ToString("00"))
                {
                    run = 1;
                }

            }
            else {
                run = 1;
            }

            string serial = this.StrRight(year.ToString(), 2) + "" + mount.ToString("00")+run.ToString("00000");
            txtlastserial.Text = serial;

            txtqty.Enabled = true;
            txtremart.Enabled = true;
        }