本文整理汇总了C#中CurtDevDataContext.indexPart方法的典型用法代码示例。如果您正苦于以下问题:C# CurtDevDataContext.indexPart方法的具体用法?C# CurtDevDataContext.indexPart怎么用?C# CurtDevDataContext.indexPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurtDevDataContext
的用法示例。
在下文中一共展示了CurtDevDataContext.indexPart方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public ActionResult Add(int partID = 0, string shortDesc = "", int status = 0, string oldPartNumber = "", int priceCode = 0, int classID = 0, string btnSubmit = "", string btnContinue = "", string upc = "", bool featured = false, int? ACESPartTypeID = null)
{
CurtDevDataContext db = new CurtDevDataContext();
List<string> error_messages = new List<string>();
Part new_part = new Part{
partID = partID,
shortDesc = shortDesc,
status = status,
oldPartNumber = oldPartNumber,
priceCode = priceCode,
classID = classID,
dateAdded = DateTime.Now,
dateModified = DateTime.Now,
featured = featured,
ACESPartTypeID = ACESPartTypeID
};
// Validate the partID and shortDesc fields
if(partID == 0){ error_messages.Add("You must enter a part number."); }
if(shortDesc.Length == 0){ error_messages.Add("You must enter a short description."); }
if (upc.Trim().Length == 0) { error_messages.Add("You must enter a UPC."); }
int existing_part = 0;
// Make sure we don't have a product with this partID
existing_part = (from p in db.Parts
where p.partID.Equals(partID)
select p).Count();
if (existing_part != 0) { error_messages.Add("This part number exists."); }
if (error_messages.Count == 0) { // No errors, add the part
try {
db.Parts.InsertOnSubmit(new_part);
db.SubmitChanges();
ProductModels.SaveAttribute(0,new_part.partID, "UPC", upc);
db.indexPart(new_part.partID);
if (btnContinue != "") { // Redirect to add more part information
return RedirectToAction("edit", new { partID = new_part.partID });
} else { // Redirect to product index page
return RedirectToAction("index");
}
} catch (Exception e) {
error_messages.Add(e.Message);
}
}
ViewBag.error_messages = error_messages;
// Get all the parts in the database :: This will allow the user to create related parts
ViewBag.parts = ProductModels.GetAllParts();
// Get the product classes
ViewBag.classes = ProductModels.GetClasses();
return View();
}
示例2: Edit
public ActionResult Edit(int partID = 0, string shortDesc = "", int status = 0, string oldPartNumber = "", int priceCode = 0, int classID = 0, string btnSubmit = "", string btnContinue = "", string upc = "", bool featured = false, int? ACESPartTypeID = null)
{
CurtDevDataContext db = new CurtDevDataContext();
List<string> error_messages = new List<string>();
Part part = new Part();
part = (from p in db.Parts
where p.partID.Equals(partID)
select p).FirstOrDefault<Part>();
part.partID = partID;
part.shortDesc = shortDesc;
part.status = status;
if (status == 900) {
// find eMAP pricing and set enforced = 0
Price eMapPrice = db.Prices.Where(x => x.priceType == "eMap" && x.partID == partID).FirstOrDefault<Price>();
if (eMapPrice != null) {
eMapPrice.enforced = false;
eMapPrice.dateModified = DateTime.Now;
db.SubmitChanges();
}
}
part.oldPartNumber = oldPartNumber;
part.priceCode = priceCode;
part.classID = classID;
part.dateModified = DateTime.Now;
part.featured = featured;
part.ACESPartTypeID = ACESPartTypeID;
// Validate the partID and shortDesc fields
if (partID == 0) { error_messages.Add("You must enter a part number."); }
if (shortDesc.Length == 0) { error_messages.Add("You must enter a short description."); }
if (upc.Trim().Length == 0) { error_messages.Add("You must enter a UPC."); }
if (error_messages.Count == 0) { // No errors, add the part
try {
db.SubmitChanges();
if (ProductModels.HasAttribute(partID, "UPC")) {
ProductModels.UpdateAttributeByField(partID, "UPC", upc);
} else {
ProductModels.SaveAttribute(0,partID, "UPC", upc);
}
db.indexPart(part.partID);
if(btnSubmit != ""){ // Redirect to product index page
return RedirectToAction("index");
}
} catch (Exception e) {
error_messages.Add(e.Message);
}
}
// Save the error messages into the bag
ViewBag.error_messages = error_messages;
// Get the ConvertedPart version of this part object
ViewBag.part = ProductModels.GetPart(part.partID);
ViewBag.UPC = ProductModels.GetAttribute(part.partID, "UPC");
// Get the product classes
ViewBag.classes = ProductModels.GetClasses();
ViewBag.PartTypes = new ACES().GetPartTypes();
ViewBag.active_tab = "info";
return View();
}
示例3: Clone
//.........这里部分代码省略.........
List<ContentBridge> new_content = new List<ContentBridge>();
List<ContentBridge> contents = (from cb in db.ContentBridges
where cb.partID == partID
select cb).ToList<ContentBridge>();
foreach (ContentBridge cont in contents) {
Content c = db.Contents.Where(x => x.contentID.Equals(cont.contentID)).FirstOrDefault();
Content new_c = new Content {
cTypeID = c.cTypeID,
text = c.text
};
db.Contents.InsertOnSubmit(new_c);
db.SubmitChanges();
ContentBridge cb = new ContentBridge {
partID = new_part.partID,
contentID = new_c.contentID
};
db.ContentBridges.InsertOnSubmit(cb);
db.SubmitChanges();
}
messages.Add("Contents Cloned Successfully");
} catch {
messages.Add("There was a problem cloning the contents.");
}
}
#endregion
#region clone Vehicles
if (vehicles) {
try {
List<VehiclePart> vehiclelist = db.VehicleParts.Where(x => x.partID == partID).ToList<VehiclePart>();
foreach (VehiclePart vp in vehiclelist) {
VehiclePart vehiclepart = new VehiclePart {
partID = new_part.partID,
vehicleID = vp.vehicleID,
drilling = vp.drilling,
installTime = vp.installTime,
exposed = vp.exposed
};
db.VehicleParts.InsertOnSubmit(vehiclepart);
db.SubmitChanges();
List<VehiclePartAttribute> new_vpattr = new List<VehiclePartAttribute>();
List<VehiclePartAttribute> vpattrs = db.VehiclePartAttributes.Where(x => x.vPartID == vp.vPartID).ToList<VehiclePartAttribute>();
foreach (VehiclePartAttribute vpa in vpattrs) {
VehiclePartAttribute new_vpa = new VehiclePartAttribute {
vPartID = vehiclepart.vPartID,
value = vpa.value,
field = vpa.field,
sort = vpa.sort
};
new_vpattr.Add(new_vpa);
};
db.VehiclePartAttributes.InsertAllOnSubmit(new_vpattr);
db.SubmitChanges();
messages.Add("Vehicles Cloned Successfully");
}
} catch {
messages.Add("There was a problem cloning the vehicles.");
}
}
#endregion
#region clone Prices
if (prices) {
try {
List<Price> new_prices = new List<Price>();
List<Price> pricelist = db.Prices.Where(x => x.partID == partID).ToList<Price>();
foreach (Price prc in pricelist) {
Price price = new Price {
priceType = prc.priceType,
price1 = prc.price1,
partID = new_part.partID,
enforced = prc.enforced
};
new_prices.Add(price);
}
db.Prices.InsertAllOnSubmit(new_prices);
db.SubmitChanges();
messages.Add("Prices Cloned Successfully");
} catch {
messages.Add("There was a problem cloning the prices.");
}
}
#endregion
ImportImages(new_part.partID);
db.indexPart(new_part.partID);
messages.Add("Part Cloned Successfully.");
} catch (Exception e) {
messages.Add(e.Message);
}
} else {
messages.Add("Part Clone Failed.");
}
#endregion
return Newtonsoft.Json.JsonConvert.SerializeObject(messages);
}
示例4: DeleteVehiclePartAttribute
public static string DeleteVehiclePartAttribute(int attrID = 0)
{
try {
// Validate
if (attrID <= 0) { throw new Exception("Attribute ID is invalid."); }
// Variable Declaration
CurtDevDataContext db = new CurtDevDataContext();
VehiclePartAttribute vpa = new VehiclePartAttribute();
vpa = (from p in db.VehiclePartAttributes
where p.vpAttrID.Equals(attrID)
select p).FirstOrDefault<VehiclePartAttribute>();
int pid = vpa.vPartID;
db.VehiclePartAttributes.DeleteOnSubmit(vpa);
db.SubmitChanges();
updateVehicleAttributeSort(getVehiclePartAttributeIDs(pid));
db.indexPart(vpa.VehiclePart.partID);
UpdatePart(vpa.VehiclePart.partID);
return "";
} catch (Exception e) {
return e.Message;
}
}
示例5: SaveAttribute
public static PartAttribute SaveAttribute(int attrID = 0, int partID = 0, string field = "", string value = "")
{
// Validate fields
if (partID <= 0) { throw new Exception("Part ID is invalid."); }
if (field.Length <= 0) { throw new Exception("Field is invalid."); }
if (value.Length <= 0) { throw new Exception("Value is invalid."); }
if (field.ToUpper() == "UPC") { // Validate UPC
if (!ValidateUPC(value)) {
throw new Exception("UPC exists.");
}
}
// Declare objects
CurtDevDataContext db = new CurtDevDataContext();
PartAttribute pa = new PartAttribute();
if (attrID == 0) {
// Add New Attribute
bool exists = db.PartAttributes.Where(x => x.partID == partID).Where(x => x.field == field).Count() > 0;
if (exists) {
throw new Exception("This attribute already exists!");
}
pa = new PartAttribute {
partID = partID,
field = field.Trim(),
value = value.Trim(),
sort = (db.PartAttributes.Where(x => x.partID.Equals(partID)).OrderByDescending(x => x.sort).Select(x => x.sort).FirstOrDefault() + 1)
};
// Commit to databse
db.PartAttributes.InsertOnSubmit(pa);
} else {
// Update Existing Attribute
// Retrive PartAttribute
pa = (from p in db.PartAttributes
where p.pAttrID.Equals(attrID)
select p).FirstOrDefault<PartAttribute>();
// Update values
pa.partID = partID;
pa.field = field.Trim();
pa.value = value.Trim();
}
// Commit to databse
db.SubmitChanges();
UpdateAttributeSort(getAttributeIDs(partID));
db.indexPart(partID);
UpdatePart(partID);
// Return PartAttribute
return pa;
}
示例6: DeleteVehiclePart
public static string DeleteVehiclePart(int vehicleID = 0, int partID = 0)
{
try {
if (vehicleID == 0 || partID == 0) {
throw new Exception("Invalid data.");
}
CurtDevDataContext db = new CurtDevDataContext();
VehiclePart vp = new VehiclePart();
List<VehiclePartAttribute> attributes = new List<VehiclePartAttribute>();
vp = (from v in db.VehicleParts
where v.vehicleID.Equals(vehicleID) && v.partID.Equals(partID)
select v).FirstOrDefault<VehiclePart>();
attributes = (from vpa in db.VehiclePartAttributes
join v in db.VehicleParts on vpa.vPartID equals v.vPartID
where v.vehicleID == vehicleID && v.partID == partID
select vpa).ToList<VehiclePartAttribute>();
db.VehiclePartAttributes.DeleteAllOnSubmit(attributes);
db.SubmitChanges();
db.VehicleParts.DeleteOnSubmit(vp);
db.SubmitChanges();
db.indexPart(partID);
UpdatePart(partID);
return "";
} catch (Exception e) {
return e.Message;
}
}
示例7: DeleteAttribute
public static void DeleteAttribute(int attrID = 0)
{
// Validate
if (attrID <= 0) { throw new Exception("Attribute ID is invalid."); }
// Variable Declaration
CurtDevDataContext db = new CurtDevDataContext();
PartAttribute pa = new PartAttribute();
pa = (from p in db.PartAttributes
where p.pAttrID.Equals(attrID)
select p).FirstOrDefault<PartAttribute>();
int pid = pa.partID;
db.PartAttributes.DeleteOnSubmit(pa);
db.SubmitChanges();
UpdateAttributeSort(getAttributeIDs(pid));
db.indexPart(pid);
UpdatePart(pid);
}
示例8: AddVehicle
public static string AddVehicle(int partID = 0, int vehicleID = 0)
{
try {
CurtDevDataContext db = new CurtDevDataContext();
if (partID > 0 && vehicleID > 0) {
List<int> options = getAllCarryOverParts(partID);
foreach (int partnum in options) {
// Check to make sure a record doesn't already exist for this part and vehicle
int existing = (from vp in db.VehicleParts
where vp.partID.Equals(partnum) && vp.vehicleID.Equals(vehicleID)
select vp).Count();
if (existing == 0) {
VehiclePart vp = new VehiclePart {
vehicleID = vehicleID,
partID = partnum,
exposed = "",
drilling = "",
installTime = 0
};
db.VehicleParts.InsertOnSubmit(vp);
db.SubmitChanges();
db.indexPart(partnum);
}
}
UpdatePart(partID);
} else {
throw new Exception("Invalid partID or vehicleID");
}
return "";
} catch (Exception e) {
return "{\"error\":\"" + e.Message + "\"}";
}
}
示例9: UpdateAttributeByField
internal static void UpdateAttributeByField(int partID = 0, string key = "", string value = "")
{
CurtDevDataContext db = new CurtDevDataContext();
PartAttribute attribute = (from a in db.PartAttributes
where a.partID.Equals(partID) && a.field.ToLower().Equals(key.Trim().ToLower())
select a).FirstOrDefault <PartAttribute>();
attribute.value = value;
db.SubmitChanges();
db.indexPart(partID);
UpdatePart(partID);
}
示例10: UpdateVehicle
public static VehiclePart UpdateVehicle(int partID = 0, int vehicleID = 0, string drilling = "", string exposed = "", int installTime = 0)
{
// Variable initializers
CurtDevDataContext db = new CurtDevDataContext();
VehiclePart vp = new VehiclePart();
// Get the VehiclePart that we want to work with
vp = (from v in db.VehicleParts
where v.vehicleID.Equals(vehicleID) && v.partID.Equals(partID)
select v).FirstOrDefault<VehiclePart>();
if (vp == null) { throw new Exception("VehiclePart not found."); }
// Update fields and commit to database
vp.drilling = drilling;
vp.exposed = exposed;
vp.installTime = installTime;
db.SubmitChanges();
db.indexPart(partID);
return vp;
}