public string Get_PackingByCode(string code) { PackingMaster packingMaster = _Packingrepo.Get_PackingByCode(code.ToLower()); string myjsonresult = (new JavaScriptSerializer()).Serialize(packingMaster); return(myjsonresult); }
public string Check_PackingMaster(string code) { string result = string.Empty; PackingMaster m = _Packingrepo.Get_PackingByCode(code); if (m != null) { result = new JavaScriptSerializer().Serialize(m); } return(result); }
//Add:New Packing Master record public bool Add_PackingMaster(PackingMaster pack) { bool status = false; if (pack != null) { db.PackingMasters.InsertOnSubmit(pack); db.SubmitChanges(); status = true; } return(status); }
//Delete:PackingMaster by id public bool Delete_PackingMaster(int id) { bool status = false; PackingMaster pack = db.PackingMasters.FirstOrDefault(x => x.Id == id && x.IsDeleted == false); if (pack != null) { pack.IsDeleted = true; db.SubmitChanges(); status = true; } return(status); }
//: Get Packing Master By Id For Update private void GetPackingForUpdate() { if (Request.QueryString["Id"] != null) { divoptions.Style.Add("display", "block"); txtPackingCode.Enabled = false; int id = Convert.ToInt32(Request.QueryString["Id"].ToString()); PackingMaster _model = repo.Get_PackingMasterById(id); if (_model != null) { txtPackingCode.Text = _model.PackingCode.ToString(); txtPackingName.Text = _model.PackingName.ToString(); ddlpackinguom.SelectedValue = _model.PackingUOM.ToString(); txtPackingwt.Text = _model.PackingWT.ToString(); } } }
public bool SavePacking(PackingModel model) { try { PackingMaster ms = new PackingMaster(); ms.article = model.article; ms.item = model.item; ms.actualWeight = model.actualWeight1; ms.packingType = model.packingType; _tRSEntities.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
//: Retrun the Previous record from packing master protected void Previous_Record_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["Id"].ToString()); PackingMaster next = null; try { next = repo.GetPackingMasters_List().Where(x => x.Id < id && x.IsDeleted == false).OrderByDescending(i => i.Id).FirstOrDefault(); } catch { } if (next != null) { Response.Redirect("AddEdit.aspx?id=" + next.Id.ToString()); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('No more records founds.')", true); } }
//: Save Packing Master private void AddPacking() { if (Request.QueryString["Id"] == null) { try { PackingMaster pp = repo.Get_PackingByCode(txtPackingCode.Text.Trim()); if (pp != null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same packing code Exist! Please try again');", true); } else { PackingMaster packingMaster = new PackingMaster(); packingMaster.PackingCode = txtPackingCode.Text.ToString(); packingMaster.PackingName = txtPackingName.Text.ToString(); packingMaster.PackingUOM = ddlpackinguom.SelectedValue.ToString(); packingMaster.PackingWT = txtPackingwt.Text.ToString(); packingMaster.IsDeleted = false; if (repo.Add_PackingMaster(packingMaster)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Save Successfully')", true); HtmlMeta meta = new HtmlMeta { HttpEquiv = "Refresh", Content = "1;url=AddEdit.aspx" }; this.Page.Controls.Add(meta); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true); } } }
//Update: Packing Master private void UpdatePacking() { int id = Convert.ToInt32(Request.QueryString["Id"].ToString()); try { PackingMaster _model = repo.GetPackingMasters_List().Where(x => x.PackingCode == txtPackingCode.Text.Trim() && x.Id != id && x.IsDeleted == false).SingleOrDefault(); if (_model != null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same packing code exist please try again');", true); } else { PackingMaster packing = db.PackingMasters.Where(x => x.Id == id && x.IsDeleted == false).FirstOrDefault(); if (packing != null) { packing.PackingCode = txtPackingCode.Text.ToString(); packing.PackingName = txtPackingName.Text.ToString(); packing.PackingUOM = ddlpackinguom.SelectedValue.ToString(); packing.PackingWT = txtPackingwt.Text.ToString(); db.SubmitChanges(); ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Record Updated Successfully')", true); HtmlMeta meta = new HtmlMeta { HttpEquiv = "Refresh", Content = "1;url=AddEdit.aspx?id=" + id }; this.Page.Controls.Add(meta); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true); } }
public bool UpadateBooking(BookingModel model) { try { var check = _tRSEntities.BookingMasters.Where(x => x.id == model.id && x.isActive == true).FirstOrDefault(); if (check != null) { check.expectedDelivery = model.expectedDelivery; if (model.from != 0) { check.from = model.from; } if (model.to != 0) { check.to = model.to; } if (model.godownNo != 0) { check.godownNo = model.godownNo; } check.paymentType = model.paymentType; check.actualWeight = model.actualWeight; if (model.consignee != 0) { check.consignee = model.consignee; } //next day check.cnNo = model.cnNo; check.deliveryBranch = model.deliveryBranch; check.virtualGoddownNo = model.virtualGoddownNo; check.consignorDetails = model.consignorDetails; check.agentName = model.agentName; check.agentDetails = model.agentDetails; check.bookingType = model.bookingType; check.deliveryType = model.deliveryType; check.modeOfTransport = model.modeOfTransport; check.invoiceNo = model.invoiceNo; check.invoiceValue = model.invoiceValue; check.consignorInvoice = model.consignorInvoice; check.freightBasis = model.freightBasis; check.ftl = model.ftl; check.isCcAttached = model.isCcAttached; check.isCod = model.isCod; check.chargeWeight = model.chargeWeight; check.freightRate = model.freightRate; check.privateMark = model.privateMark; check.insuredBy = model.insuredBy; check.freight = model.freight; check.surcharge = model.surcharge; check.hamaliCharge = model.surcharge; check.localCartages = model.localCartages; check.doorDeliveryCharge = model.doorDeliveryCharge; check.statisticalCharges = model.statisticalCharges; check.miscellaneousCharges = model.miscellaneousCharges; check.godownCharges = model.godownCharges; check.riskCharge = model.riskCharge; check.cod = model.cod; check.branch = model.branch; check.reserveReason = model.reserveReason; check.cnFrom = model.cnFrom; check.cnTo = model.cnTo; check.srtoNo = model.srtoNo; check.lotNo = model.lotNo; check.rollNo = model.rollNo; check.meter = model.meter; check.weightInKg = model.weightInKg; check.isActive = true; var checkSinglecn = _tRSEntities.PackingMasters.ToList(); foreach (var item1 in model.singleCn) { var findSingleCn = _tRSEntities.PackingMasters.Where(x => x.id == item1.id).FirstOrDefault(); PackingMaster pk = new PackingMaster(); findSingleCn.actualWeight = item1.actualWeight1; findSingleCn.packingType = item1.packingType; findSingleCn.article = item1.article; findSingleCn.isActive = true; _tRSEntities.SaveChanges(); } _tRSEntities.SaveChanges(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
public bool SaveBooking(BookingModel model) { try { BookingMaster master = new BookingMaster(); master.cn = model.cn; master.expectedDelivery = model.expectedDelivery; if (model.from != 0) { master.from = model.from; } if (model.to != 0) { master.to = model.to; } if (model.godownNo != 0) { master.godownNo = model.godownNo; } master.paymentType = model.paymentType; master.actualWeight = model.actualWeight; if (model.consignee != 0) { master.consignee = model.consignee; } //second day master.cnNo = model.cnNo; master.deliveryBranch = model.deliveryBranch; master.virtualGoddownNo = model.virtualGoddownNo; master.consignorDetails = model.consignorDetails; master.consignor = model.consignor; master.agentName = model.agentName; master.agentDetails = model.agentDetails; master.bookingType = model.bookingType; master.deliveryType = model.deliveryType; master.modeOfTransport = model.modeOfTransport; master.invoiceNo = model.invoiceNo; master.invoiceValue = model.invoiceValue; master.consignorInvoice = model.consignorInvoice; master.freightBasis = model.freightBasis; master.ftl = model.ftl; master.isCcAttached = model.isCcAttached; master.isCod = model.isCod; master.chargeWeight = model.chargeWeight; master.freightRate = model.freightRate; master.privateMark = model.privateMark; master.insuredBy = model.insuredBy; master.freight = model.freight; master.surcharge = model.surcharge; master.hamaliCharge = model.hamaliCharge; master.localCartages = model.localCartages; master.doorDeliveryCharge = model.doorDeliveryCharge; master.statisticalCharges = model.statisticalCharges; master.miscellaneousCharges = model.miscellaneousCharges; master.godownCharges = model.miscellaneousCharges; master.cod = model.cod; master.riskCharge = model.riskCharge; master.branch = model.branch; master.reserveReason = model.reserveReason; master.cnFrom = model.cnFrom; master.srtoNo = model.srtoNo; master.lotNo = model.lotNo; master.meter = model.meter; master.weightInKg = model.weightInKg; master.isActive = true; _tRSEntities.BookingMasters.Add(master); _tRSEntities.SaveChanges(); PackingMaster pk = new PackingMaster(); pk.bookingId = master.id; foreach (var item in model.singleCn) { pk.actualWeight = item.actualWeight1; pk.packingType = item.packingType; pk.article = item.article; pk.isActive = true; _tRSEntities.PackingMasters.Add(pk); _tRSEntities.SaveChanges(); } return(true); } catch (Exception e) { throw e; } }
//Save: Excel File Data To Database public string SaveDataToSever(DataSet ds) { string result = string.Empty; using (DataClasses1DataContext db = new DataClasses1DataContext()) { string connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString; DataTable dt = ds.Tables[0]; int _failed = 0; int _success = 0; int _update = 0; foreach (DataRow dr in dt.Rows) { try { string _PackingCode = dr["Packing Code"].ToString(); string _PackingName = dr["Packing Name"].ToString(); string _PackingUOM = dr["Packing UOM"].ToString(); string _PackingWT = dr["Packing WT"].ToString(); var _PackingMaster = db.PackingMasters.Where(x => x.PackingCode == _PackingCode && x.IsDeleted == false).FirstOrDefault(); if (_PackingMaster != null) { if (string.IsNullOrEmpty(_PackingName)) { _failed++; } else { _PackingMaster.PackingName = _PackingName; _PackingMaster.PackingUOM = _PackingUOM; _PackingMaster.PackingWT = _PackingWT; db.SubmitChanges(); _update++; } } else { if (!string.IsNullOrEmpty(_PackingCode) && !string.IsNullOrEmpty(_PackingName)) { PackingMaster _packingmaster = db.PackingMasters.Where(x => x.PackingCode == _PackingCode && x.IsDeleted == false).FirstOrDefault(); if (_packingmaster != null) { _failed++; } else { db.PackingMasters.InsertOnSubmit(new PackingMaster { PackingCode = _PackingCode, PackingName = _PackingName, PackingUOM = _PackingUOM, PackingWT = _PackingWT, IsDeleted = false }); db.SubmitChanges(); _success++; } } else { _failed++; } } } catch { _failed++; } } result = "New Added: " + _success + " Updated: " + _update + " Failed: " + _failed + ""; } return(result); }
//Get:PackingMaster By Id public PackingMaster Get_PackingMasterById(int id) { PackingMaster pack = db.PackingMasters.FirstOrDefault(x => x.Id == id && x.IsDeleted == false); return(pack); }
//Save:Excel data to the server public string SaveDataToServer(DataSet ds) { string result = string.Empty; using (DataClasses1DataContext db = new DataClasses1DataContext()) { string connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString; DataTable dt = ds.Tables[0]; int _failed = 0; int _success = 0; int _update = 0; foreach (DataRow dr in dt.Rows) { try { string _PackingCode = dr["Packing Code"].ToString(); string _Matclascode = dr["Material Classification Code"].ToString(); string _MaterialCode = dr["Material Code"].ToString(); string _MaterialDesc = dr["Material Desc"].ToString(); MaterialClassification mc = db.MaterialClassifications.FirstOrDefault(x => x.MaterialClassificationCode == _Matclascode && x.IsDeleted == false); PackingMaster pm = db.PackingMasters.Where(x => x.PackingCode == _PackingCode && x.IsDeleted == false).FirstOrDefault(); var data = db.tblMaterials.Where(x => x.MaterialCode == _MaterialCode && x.IsDeleted == false).FirstOrDefault(); if (data != null) { if (string.IsNullOrEmpty(_PackingCode) && string.IsNullOrEmpty(_Matclascode) && string.IsNullOrEmpty(_MaterialDesc)) { _failed++; } else { data.MaterialDesc = _MaterialDesc; data.PackingCode = _PackingCode; data.MaterialClassificationCodeId = _Matclascode; db.SubmitChanges(); _update++; } } else { if (!string.IsNullOrEmpty(_MaterialCode) && !string.IsNullOrEmpty(_MaterialDesc) && !string.IsNullOrEmpty(_PackingCode) && !string.IsNullOrEmpty(_Matclascode)) { tblMaterial _tblmaterial = db.tblMaterials.Where(x => x.MaterialCode == _MaterialCode && x.IsDeleted == false).FirstOrDefault(); if (_tblmaterial != null) { _failed++; } else { db.tblMaterials.InsertOnSubmit(new tblMaterial { MaterialCode = _MaterialCode, MaterialDesc = _MaterialDesc, PackingCodeId = _PackingCode, MaterialClassificationCodeId = _Matclascode, IsDeleted = false }); db.SubmitChanges(); _success++; } } else { _failed++; } } } catch { _failed++; } } result = "New Added: " + _success + " Updated: " + _update + " Failed: " + _failed + ""; } return(result); }