private void setParameter(iSqlParameter[] parms, CartInfo info) { try { int i = -1; parms[++i].Value = CFunctions.SetDBString(info.Name) + info.Id.ToString(); parms[++i].Value = info.Status; parms[++i].Value = info.Markas; parms[++i].Value = CFunctions.SetDBDatetime(info.Timeupdate); parms[++i].Value = CFunctions.SetDBDatetime(info.Timecomplete); parms[++i].Value = CFunctions.SetDBString(info.Lang); parms[++i].Value = info.Memberid; parms[++i].Value = info.Paymenttype; parms[++i].Value = info.Amount; parms[++i].Value = info.Shippingfee; parms[++i].Value = info.Discountfee; parms[++i].Value = CFunctions.SetDBString(info.Couponcode); parms[++i].Value = info.Checkout; parms[++i].Value = CFunctions.SetDBString(info.Note); parms[++i].Value = CFunctions.SetDBString(info.Shipping_Name); parms[++i].Value = CFunctions.SetDBString(info.Shipping_Address); parms[++i].Value = CFunctions.SetDBString(info.Shipping_Address2); parms[++i].Value = CFunctions.SetDBString(info.Shipping_City); parms[++i].Value = CFunctions.SetDBString(info.Shipping_District); parms[++i].Value = info.Shipping_Nationalid; parms[++i].Value = CFunctions.SetDBString(info.Shipping_Zipcode); parms[++i].Value = CFunctions.SetDBString(info.Shipping_Phone); parms[++i].Value = CFunctions.SetDBString(info.Shipping_Email); parms[++i].Value = CFunctions.SetDBString(info.Billing_Name); parms[++i].Value = CFunctions.SetDBString(info.Billing_Address); parms[++i].Value = CFunctions.SetDBString(info.Billing_Address2); parms[++i].Value = CFunctions.SetDBString(info.Billing_City); parms[++i].Value = CFunctions.SetDBString(info.Billing_District); parms[++i].Value = info.Billing_Nationalid; parms[++i].Value = CFunctions.SetDBString(info.Billing_Zipcode); parms[++i].Value = CFunctions.SetDBString(info.Billing_Phone); parms[++i].Value = CFunctions.SetDBString(info.Billing_Email); parms[++i].Value = info.Id; return; } catch (Exception ex) { throw ex; } }
private bool Saveitem(iSqlTransaction trans, CartInfo info) { try { if (trans == null || info == null) return false; string SQL = string.Empty; if (info.Id == 0) { SQL = SQL_INSERT; info.Id = (int)HELPER.getNewID(trans, TABLENAME); iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } else if (HELPER.isExist(trans, TABLENAME, info.Id)) { SQL = SQL_UPDATE; iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } else { SQL = SQL_INSERT; info.Id = (int)HELPER.getNewID(trans, TABLENAME); iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } return true; } catch (Exception ex) { throw ex; } }
public bool Save(CartInfo info) { try { using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { using (iSqlTransaction trans = iConn.BeginTransaction()) { try { if (this.Saveitem(trans, info)) (new CCartitem(LANG)).Save(trans, info.Id, info.lCartitem); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } iConn.Close(); } return true; } catch (Exception ex) { throw ex; } }
private CartInfo getDataReader(iSqlDataReader dar) { try { int i = -1; CartInfo info = new CartInfo(); info.Name = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Status = dar.IsDBNull(++i) ? (int)CConstants.State.Status.Waitactive : dar.GetInt32(i); info.Markas = dar.IsDBNull(++i) ? (int)CConstants.State.MarkAs.None : dar.GetInt32(i); info.Timeupdate = dar.IsDBNull(++i) ? new DateTime(0) : dar.GetDateTime(i); info.Timecomplete = dar.IsDBNull(++i) ? new DateTime(0) : dar.GetDateTime(i); info.Lang = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Memberid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Membername = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Paymenttype = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Amount = dar.IsDBNull(++i) ? 0 : Math.Round(dar.GetFloat(i)); info.Shippingfee = dar.IsDBNull(++i) ? 0 : Math.Round(dar.GetFloat(i)); info.Discountfee = dar.IsDBNull(++i) ? 0 : Math.Round(dar.GetFloat(i)); info.Couponcode = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Checkout = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Note = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Name = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Address = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Address2 = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_City = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_District = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Nationalid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Shipping_Zipcode = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Phone = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Email = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Shipping_Nationalname = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Name = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Address = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Address2 = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_City = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_District = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Nationalid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Billing_Zipcode = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Phone = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Email = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Billing_Nationalname = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i); info.Id = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Rownumber = dar.IsDBNull(++i) ? 0 : dar.GetInt64(i); return info; } catch (Exception ex) { throw ex; } }
private bool Order_MailToUser(CartInfo CARTINFO) { try { string content = this.Gettemplate("MailToUser.Order"); if (content == null) return false; string subject = "Order " + CARTINFO.Name; content = content.Replace("$VAR_WEBSITE$", CConstants.WEBSITE); content = content.Replace("$VAR_TIMEUPDATE$", CARTINFO.eTimeupdate); string cartlist = ""; string cartlisttemplate = CCommon.Get_Definephrase(Definephrase.Cart_listtemplate); foreach (CartitemInfo cartitem in CARTINFO.lCartitem) { string item = cartlisttemplate.Replace("$VAR_PRODUCTNAME$", cartitem.Productname); item = item.Replace("$VAR_QUANTITY$", cartitem.Quantity.ToString()); item = item.Replace("$VAR_AMOUNT$", cartitem.eAmount); cartlist += item; } content = content.Replace("$VAR_CARTLIST$", cartlist); content = content.Replace("$VAR_AMOUNTTOTAL$", CARTINFO.eAmount); content = content.Replace("$VAR_NAME$", CARTINFO.iMember.Fullname); content = content.Replace("$VAR_ADDRESS$", CARTINFO.iMember.iProfile.Address + " - " + CARTINFO.iMember.iProfile.Cityname + " - " + CARTINFO.iMember.iProfile.Nationalname); content = content.Replace("$VAR_PHONE$", CARTINFO.iMember.iProfile.Phone); content = content.Replace("$VAR_USERNAME$", CARTINFO.iMember.Username); content = content.Replace("$VAR_SHIPPING_ADDRESS$", CARTINFO.Shipping_Address + " - " + CARTINFO.Shipping_City + " - " + CARTINFO.Shipping_Nationalname); content = content.Replace("$VAR_SHIPPING_NAME$", CARTINFO.Shipping_Name); content = content.Replace("$VAR_SHIPPING_PHONE$", CARTINFO.Shipping_Phone); content = content.Replace("$VAR_PAYMENTNAME$", CARTINFO.iPayment.Name); content = content.Replace("$VAR_PAYMENTNOTE$", CARTINFO.iPayment.Note); content = content.Replace("$VAR_NOTE$", CARTINFO.Note); content = content.Replace("$VAR_LANG$", LANG); content = content.Replace("$VAR_WEBSITE$", CConstants.WEBSITE); this.SendMailToUser(CARTINFO.iMember.Username, subject, content); return true; } catch { return false; } }