private void radButtonElement1_Click(object sender, EventArgs e) { try { radGridView1.EndEdit(); radGridView1.EndUpdate(); using (DataClasses1DataContext db = new DataClasses1DataContext()) { int rows1 = 0; foreach (GridViewRowInfo rd in radGridView1.Rows) { if (Convert.ToBoolean(rd.Cells["S"].Value)) { mh_Item im = db.mh_Items.Where(m => m.InternalNo == rd.Cells["InternalNo"].Value.ToSt()).FirstOrDefault(); if (im != null) { rows1 += 1; mh_ShipmentDTTemp st = new mh_ShipmentDTTemp(); st.RNo = rows1; st.SSNo = CodeNo; st.UserID = ClassLib.Classlib.User; st.ItemNo = rd.Cells["InternalNo"].Value.ToSt(); st.ItemName = im.InternalName; st.Description = im.InternalDescription; st.Qty = 1; st.PCSUnit = 1; st.LocationItem = im.Location; st.UnitPrice = im.StandardPrice; st.Amount = im.StandardPrice * 1; st.Active = true; st.UOM = im.BaseUOM; db.mh_ShipmentDTTemps.InsertOnSubmit(st); db.SubmitChanges(); } } } } } catch { } this.Close(); }
private void radButtonElement1_Click(object sender, EventArgs e) { if (dgvData.Rows.Count <= 0) { return; } try { dgvData.EndEdit(); dgvData.EndUpdate(); using (DataClasses1DataContext db = new DataClasses1DataContext()) { int rows1 = 0; foreach (GridViewRowInfo rd in dgvData.Rows) { if (Convert.ToBoolean(rd.Cells["S"].Value)) { decimal Qty = 0; decimal UnitPrice = 0; decimal Pcsunit = 0; mh_Item im = db.mh_Items.Where(m => m.InternalNo == rd.Cells["ItemNo"].Value.ToSt()).FirstOrDefault(); if (im != null) { decimal.TryParse(rd.Cells["Remain"].Value.ToString(), out Qty); } //decimal.TryParse(rd.Cells["Qty"].Value.ToString(), out Qty); decimal.TryParse(rd.Cells["UnitPrice"].Value.ToString(), out UnitPrice); decimal.TryParse(rd.Cells["PCSUnit"].Value.ToString(), out Pcsunit); //decimal ShipQty = dbClss.TDe(rd.Cells["ShipQty"].Value); if (UnitPrice == 0) { UnitPrice = im.StandardPrice; } if (Pcsunit == 0) { Pcsunit = 1; } //if (Qty == 0) // Qty = 1; rows1 += 1; mh_ShipmentDTTemp st = new mh_ShipmentDTTemp(); st.RNo = rows1; st.SSNo = SHNo; st.UserID = ClassLib.Classlib.User; st.ItemNo = rd.Cells["ItemNo"].Value.ToSt(); st.ItemName = im.InternalName; st.Description = im.InternalDescription; st.Qty = Qty; st.PCSUnit = Pcsunit; st.LocationItem = im.Location; st.UnitPrice = UnitPrice; st.Amount = UnitPrice * Qty; st.Active = true; st.OutShip = Qty; if (!Convert.ToString(rd.Cells["Unit"].Value.ToSt()).Equals("")) { st.UOM = rd.Cells["Unit"].Value.ToSt(); } else { st.UOM = im.SalesUOM; } st.RefDocNo = rd.Cells["SONo"].Value.ToSt(); st.RefId = Convert.ToInt32(rd.Cells["id"].Value); st.VatType = dbClss.TSt(rd.Cells["VatType"].Value); db.mh_ShipmentDTTemps.InsertOnSubmit(st); db.SubmitChanges(); } } } } catch { } this.Close(); }