Esempio n. 1
0
 private void radButtonElement1_Click(object sender, EventArgs e)
 {
     if (row >= 0)
     {
         string Code = radGridView1.Rows[row].Cells["Code"].Value.ToString();
         //delete
         if (MessageBox.Show("คุณต้องการลบ [ " + Code + " ] หรือไม่ ?", "ลบรายการ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             using (DataClasses1DataContext db = new DataClasses1DataContext())
             {
                 tb_MapItemTPIC tb = db.tb_MapItemTPICs.Where(m => m.Code == Code).FirstOrDefault();
                 if (tb != null)
                 {
                     db.tb_MapItemTPICs.DeleteOnSubmit(tb);
                     db.SubmitChanges();
                     MessageBox.Show("ลบเรียบร้อยแล้ว!");
                     DataLoad();
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            //Upload

            try
            {
                // tb_CheckStockList <= Insert to this table
                //Update Status tb_CheckStock to "Waiting Check"
                //สามารถอัพโหลดใหม่ได้ โดยการ ให้ลบ ข้อมูลเก่าทั้งหมดออกก่อน

                //    string DKUBU, ItemCode, ItemDescription, Type
                //, Revision, ExclusionClass, StorageWorkCenter, StorageWorkCenterName
                //, CurrentInventory, InventoryValue, StockBeforeInventory, PhysicalInventoryValue
                //, UnitOfMeasure = "";

                int C = 0;
                this.Cursor = Cursors.WaitCursor;
                using (DataClasses1DataContext db = new DataClasses1DataContext())
                {
                    //radProgressBarElement1.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                    //radProgressBarElement1.Minimum = 0;
                    //radProgressBarElement1.Maximum = dt_d.Rows.Count;

                    foreach (DataRow dr in dt_d.Rows)
                    {
                        //DKUBU = ""; ItemCode = ""; ItemDescription = ""; Type = "";
                        //Revision = ""; ExclusionClass = ""; StorageWorkCenter = ""; StorageWorkCenterName = "";
                        //CurrentInventory = ""; InventoryValue = ""; StockBeforeInventory = ""; PhysicalInventoryValue = "";
                        //UnitOfMeasure = "";

                        //d = dr["DATE"].ToString();
                        if (!dbClss.TSt(dr["Code"]).Equals(""))
                        {
                            var h = (from ix in db.tb_MapItemTPICs
                                     where ix.Code == dbClss.TSt(dr["Code"])
                                     select ix).ToList();
                            if (h.Count > 0)
                            {
                                var hh = (from ix in db.tb_MapItemTPICs
                                          where ix.Code == dbClss.TSt(dr["Code"])
                                          select ix).First();

                                hh.CustItemNo   = dbClss.TSt(dr["CustItemNo"]);
                                hh.Code         = dbClss.TSt(dr["Code"]);
                                hh.CustItemName = dbClss.TSt(dr["CustItemName"]);
                                hh.CustomerNo   = dbClss.TSt(dr["CustomerNo"]);
                                hh.CustomerName = dbClss.TSt(dr["CustomerName"]);
                                hh.Ac           = 1;
                                hh.DWG          = "-";
                                db.SubmitChanges();
                            }
                            else
                            {
                                tb_MapItemTPIC u = new tb_MapItemTPIC();
                                u.CustItemNo   = dbClss.TSt(dr["CustItemNo"]);
                                u.Code         = dbClss.TSt(dr["Code"]);
                                u.CustItemName = dbClss.TSt(dr["CustItemName"]);
                                u.CustomerNo   = dbClss.TSt(dr["CustomerNo"]);
                                u.CustomerName = dbClss.TSt(dr["CustomerName"]);
                                u.Ac           = 1;
                                u.DWG          = "-";
                                db.tb_MapItemTPICs.InsertOnSubmit(u);
                                db.SubmitChanges();
                            }
                            C += 1;
                        }
                    }

                    if (C > 0)
                    {
                        MessageBox.Show("Import data Complete.");
                    }
                    else
                    {
                        MessageBox.Show("ไม่พบข้อมูล!");
                    }

                    //radProgressBarElement1.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                }
                lblSS.Visible    = false;
                txtPartFile.Text = "";
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            finally { this.Cursor = Cursors.Default; }
        }