Exemplo n.º 1
0
 private void LoadDataDefault()
 {
     try
     {
         using (DataClasses1DataContext db = new DataClasses1DataContext())
         {
             tb_Path ph = db.tb_Paths.Where(p => p.PathCode == "Image").FirstOrDefault();
             if (ph != null)
             {
                 PathFile = ph.PathFile;
             }
         }
     }
     catch { }
 }
Exemplo n.º 2
0
 private void Saveclick()
 {
     if (!txtItemNo.Text.Equals("") && !txtPathImage.Text.Equals(""))
     {
         if (MessageBox.Show("ต้องการบันทึก ?", "บันทึก", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 string Path = "";
                 using (DataClasses1DataContext db = new DataClasses1DataContext())
                 {
                     tb_Path ph = db.tb_Paths.Where(p => p.PathCode == "Image").FirstOrDefault();
                     if (ph != null)
                     {
                         Path = ph.PathFile;
                     }
                     tb_ItemList uck = db.tb_ItemLists.Where(u => u.CodeNo == txtItemNo.Text).FirstOrDefault();
                     if (uck != null)
                     {
                         //un.UserID = txtUserID.Text;
                         UploadImage(Path);
                         uck.PathImage = txtImage.Text;
                         db.SubmitChanges();
                         dbClss.AddHistory("ListItem", "แก้ไขรูป", "แก้ไขรายละเอียด  [" + txtItemNo.Text + "] ", "จากเครื่อง " + System.Environment.MachineName);
                     }
                     else
                     {
                         UploadImage(Path);
                         tb_ItemList im = new tb_ItemList();
                         im.CodeNo    = txtItemNo.Text;
                         im.PathImage = txtImage.Text;
                         db.tb_ItemLists.InsertOnSubmit(im);
                         db.SubmitChanges();
                         dbClss.AddHistory("ListItem", "เพิ่มรูป", "ทำการเพิ่มรายการชื่อ  [" + txtItemNo.Text + "] เข้าระบบ", "จากเครื่อง " + System.Environment.MachineName);
                     }
                     MessageBox.Show("Save Completed!");
                 }
             }
             catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
         }
     }
     else
     {
         MessageBox.Show("Path Image is Empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            //Print TAG//
            try
            {
                this.Cursor = Cursors.WaitCursor;
                int    Qty    = 0;
                int    snp    = 1;
                int    TAG    = 0;
                int    a      = 0;
                double ap     = 0;
                int    Remain = 0;
                int.TryParse(txtQty.Text, out Qty);
                int.TryParse(txtsNP.Text, out snp);

                string OfTAG  = "";
                string QrCode = "";

                if (Qty > 0)
                {
                    // string TMNo = dbClss.GetSeriesNo(2, 2);
                    if (Qty != 0 && snp != 0)
                    {
                        a  = 0;
                        ap = (Qty % snp);
                        if (ap > 0)
                        {
                            a = 1;
                        }
                        TAG = Convert.ToInt32(Math.Floor((Convert.ToDouble(Qty) / Convert.ToDouble(snp)) + a));//.ToString("###");

                        //txtOftag.Text = Math.Ceiling((double)1.7 / 10).ToString("###");

                        Remain = Qty;
                    }
                    int    C         = 0;
                    string ImagePath = "";
                    string ImageName = "";
                    using (DataClasses1DataContext db = new DataClasses1DataContext())
                    {
                        tb_Path ph = db.tb_Paths.Where(p => p.PathCode == "Image").First();
                        if (ph != null)
                        {
                            ImagePath = ph.PathFile;
                        }
                        tb_ItemList il = db.tb_ItemLists.Where(i => i.CodeNo == txtPartNo.Text).FirstOrDefault();
                        if (il != null)
                        {
                            ImageName = il.PathImage;
                        }


                        var tm = db.tb_ProductTAGs.Where(t => t.UserID.ToLower() == dbClss.UserID.ToLower()).ToList();
                        if (tm.Count > 0)
                        {
                            db.tb_ProductTAGs.DeleteAllOnSubmit(tm);
                            db.SubmitChanges();
                        }

                        for (int i = 1; i <= TAG; i++)
                        {
                            OfTAG  = "";
                            QrCode = "";
                            if (Remain > snp)
                            {
                                Qty    = snp;
                                Remain = Remain - snp;
                            }
                            else
                            {
                                Qty    = Remain;
                                Remain = 0;
                            }
                            OfTAG  = i + "of" + TAG;
                            QrCode = "";
                            QrCode = "PD," + txtBomNo.Text + "," + Qty + "," + snp + "," + txtLotNo.Text + "," + OfTAG + "," + txtPartNo.Text;
                            //MessageBox.Show(QrCode);
                            byte[] barcode = dbClss.SaveQRCode2D(QrCode);

                            ///////////////////////////////
                            tb_ProductTAG ts = new tb_ProductTAG();
                            ts.UserID = dbClss.UserID;
                            ts.BOMNo  = txtBomNo.Text;
                            ts.LotNo  = txtLotNo.Text;
                            // ts. = dtDate1.Value.ToString("dd/MM/yyyy");
                            ts.QRCode   = barcode;
                            ts.PartName = txtPartName.Text;
                            ts.PartNo   = txtPartNo.Text;
                            ts.Machine  = Environment.MachineName;
                            ts.OFTAG    = i + "/" + TAG;
                            if (!ImageName.Equals(""))
                            {
                                ts.PathPic = ImagePath + ImageName;
                            }
                            else
                            {
                                ts.PathPic = "";
                            }
                            ts.Qty          = Qty;
                            ts.Seq          = i;
                            ts.CSTMShot     = txtCustomerShortName.Text;
                            ts.CustomerName = txtCustomerName.Text;
                            ts.CSTMItem     = txtCustItemNo.Text;
                            ts.CustItem2    = txtCustItemName.Text;

                            //ts.s = snp;
                            // ts.Company = "Nabtesco Autmotive Corporation";
                            //ts.Quantity = Qty;
                            // ts.OfTAG = i + " / " + TAG;
                            ///////////////////////////////////////////////
                            db.tb_ProductTAGs.InsertOnSubmit(ts);
                            db.SubmitChanges();
                            C += 1;
                        }
                    }
                    if (txtAC.Text == "")
                    {
                        txtAC.Text = "1";
                    }
                    Report.Reportx1.WReport  = "PDTAG";
                    Report.Reportx1.Value    = new string[3];
                    Report.Reportx1.Value[0] = txtBomNo.Text;
                    Report.Reportx1.Value[1] = dbClss.UserID;
                    // Report.Reportx1.Value[2] = txtAC.Text;

                    Report.Reportx1 op = new Report.Reportx1("FG_TAG.rpt");
                    op.Show();
                }
                else
                {
                    MessageBox.Show("Qty invalid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            this.Cursor = Cursors.Default;
        }