Exemple #1
0
 private void setParameter(iSqlParameter[] parms, ProductInfo info)
 {
     try
     {
         int i = -1;
         parms[++i].Value = CFunctions.SetDBString(info.Code);
         parms[++i].Value = CFunctions.SetDBString(info.Name);
         parms[++i].Value = CFunctions.SetDBString(info.Introduce);
         parms[++i].Value = CFunctions.SetDBString(info.Description);
         parms[++i].Value = CFunctions.SetDBString(info.Features);
         parms[++i].Value = CFunctions.SetDBString(info.Filepreview);
         parms[++i].Value = info.Cid;
         parms[++i].Value = info.Orderd == 0 ? info.Id : info.Orderd;
         parms[++i].Value = info.Status;
         parms[++i].Value = info.Markas;
         parms[++i].Value = info.Iconex;
         parms[++i].Value = CFunctions.SetDBDatetime(info.Timecreate);
         parms[++i].Value = CFunctions.SetDBDatetime(info.Timeupdate);
         parms[++i].Value = CFunctions.SetDBString(info.Username);
         parms[++i].Value = info.Viewcounter;
         parms[++i].Value = CFunctions.SetDBString(info.Provider);
         parms[++i].Value = CFunctions.SetDBString(info.Advertise);
         parms[++i].Value = info.Price;
         parms[++i].Value = info.Pricealter;
         parms[++i].Value = info.Allowcomment;
         parms[++i].Value = info.Album;
         parms[++i].Value = CFunctions.SetDBString(info.Relateditem);
         parms[++i].Value = CFunctions.SetDBString(info.Relatednews);
         parms[++i].Value = CFunctions.install_keyword(info.Code) + " " + CFunctions.install_keyword(info.Name) + " " + CFunctions.install_keyword(info.Introduce) + " " + CFunctions.install_keyword(info.Description) + " " + CFunctions.install_keyword(info.Features) + " " + CFunctions.install_keyword(info.Advertise) + " " + CFunctions.install_keyword(info.Provider) + " " + CFunctions.install_keyword(info.Cname);
         parms[++i].Value = info.Id;
         return;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        private ProductInfo getDataReader(iSqlDataReader dar)
        {
            try
            {
                int i = -1;
                ProductInfo info = new ProductInfo();
                info.Code = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Name = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Introduce = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Description = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Features = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Filepreview = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Cid = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
                info.Cname = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Orderd = dar.IsDBNull(++i) ? 0 : dar.GetInt32(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.Iconex = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Timecreate = dar.IsDBNull(++i) ? new DateTime(0) : dar.GetDateTime(i);
                info.Timeupdate = dar.IsDBNull(++i) ? new DateTime(0) : dar.GetDateTime(i);
                info.Username = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Viewcounter = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
                info.Provider = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Advertise = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Price = dar.IsDBNull(++i) ? 0 : Math.Round(dar.GetFloat(i));
                info.Pricealter = dar.IsDBNull(++i) ? 0 : Math.Round(dar.GetFloat(i), 2);
                info.Allowcomment = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
                info.Album = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i);
                info.Relateditem = dar.IsDBNull(++i) ? string.Empty : dar.GetString(i);
                info.Relatednews = 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);

                info.lCategory = (new CCategory(LANG)).Wcmm_Getlist_ofiid(info.Id, Webcmm.Id.Product);
                info.lCategoryattr = (new CCategoryattr(LANG)).Wcmm_Getlist_ofiid(info.Id, Webcmm.Id.Product);

                return info;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
 private bool Saveitem(iSqlTransaction trans, ProductInfo 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;
     }
 }
        private void Move_Info(ProductInfo source_info, int dest_cid, CProduct BLL)
        {
            if (source_info == null) return;

            ProductInfo info_copy = source_info.copy();
            info_copy.Cid = dest_cid;
            info_copy.Status = CCommon.GetStatus_upt();
            info_copy.Username = CCommon.Get_CurrentUsername();
            info_copy.Timeupdate = DateTime.Now;
            BLL.Save(info_copy);
        }
Exemple #5
0
        public bool Save(ProductInfo info)
        {
            try
            {
                using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM))
                {
                    using (iSqlTransaction trans = iConn.BeginTransaction())
                    {
                        try
                        {
                            if (this.Saveitem(trans, info))
                            {
                                new CItemcategory(LANG).Save(info.Id, Webcmm.Id.Product, info.Categoryid);
                                new CItemcategoryattr(LANG).Save(info.Id, Webcmm.Id.Product, info.Categoryattrid);
                            }

                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            throw ex;
                        }
                    }
                    iConn.Close();
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Copy_Info(ProductInfo source_info, int dest_cid, CProduct BLL)
        {
            if (source_info == null) return;

            ProductInfo info_copy = source_info.copy();
            info_copy.Id = 0;
            info_copy.Cid = dest_cid;
            info_copy.Status = CCommon.GetStatus_upt();
            info_copy.Username = CCommon.Get_CurrentUsername();
            info_copy.Timeupdate = DateTime.Now;
            info_copy.Allowcomment = source_info.Allowcomment > 0 ? 1 : 0;
            info_copy.Orderd = 0;
            BLL.Save(info_copy);
        }
        private ProductInfo Take()
        {
            try
            {
                int iid = 0;
                int.TryParse(txtId.Value, out iid);
                ProductInfo info = (new CProduct(CCommon.LANG)).Wcmm_Getinfo(iid);
                if (info == null)
                    info = new ProductInfo();
                info.Id = iid;
                info.Name = txtName.Text.Trim();
                info.Code = txtCode.Text.Trim();
                info.Introduce = txtIntroduce.Text.Trim();
                info.Description = txtDescription.Text.Trim();
                info.Price = CFunctions.IsNullOrEmpty(txtPrice.Text.Replace("$", "").Trim()) ? 0 : float.Parse(txtPrice.Text.Replace("$", "").Trim());
                info.Pricealter = CFunctions.IsNullOrEmpty(txtPricealter.Text.Replace("$", "").Trim()) ? 0 : float.Parse(txtPricealter.Text.Replace("$", "").Trim());
                info.Allowcomment = chkAllowcomment.Checked ? (info.Allowcomment > 1 ? info.Allowcomment : 1) : 0;
                info.Filepreview = Filepreview.Get();
                info.Iconex = Displaysetting.Get_Icon();
                info.Status = Displaysetting.Get_Status();
                info.Orderd = Displaysetting.Get_Orderd();
                info.Markas = Displaysetting.Get_Markas();
                info.Relateditem = Relatedproduct.Get();
                info.Relatednews = Relatednews.Get();
                info.Username = Assigntouser.Get_User();
                if (info.Id == 0)
                    info.Timecreate = DateTime.Now;
                info.Timeupdate = DateTime.Now;

                info.Cid = int.Parse(ddlCid.SelectedValue);
                info.Categoryid = CCommon.Get_FormString(Queryparam.Chkcategorymulti);
                info.Categoryattrid = CCommon.Get_FormString(Queryparam.Chkcategoryattr);

                return info;
            }
            catch
            {
                return null;
            }
        }
        private bool Save_Lang(ProductInfo info)
        {
            try
            {
                if (!CFunctions.IsMultiLanguage() || !chkSaveoption_golang.Checked) return false;

                int lang_num = CConstants.LANG_NUM;
                for (int i = 0; i < lang_num; i++)
                {
                    string lang_val = ConfigurationSettings.AppSettings["LANG_" + i];
                    if (lang_val == CCommon.LANG) continue;

                    ProductInfo lang_info = info.copy();
                    lang_info.Id = 0;
                    lang_info.Status = (int)CConstants.State.Status.Waitactive;
                    CProduct DALProduct = new CProduct(lang_val);
                    if (DALProduct.Save(lang_info))
                    {
                        if (lang_info.lFileattach != null && lang_info.lFileattach.Count > 0)
                            if (new CFileattach(lang_val).Save(lang_info.lFileattach, lang_info.Id))
                                DALProduct.Updatenum(lang_info.Id.ToString(), Queryparam.Sqlcolumn.Album, lang_info.lFileattach.Count);
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
 private bool Save(ProductInfo info)
 {
     try
     {
         if (info == null) return false;
         return (new CProduct(CCommon.LANG)).Save(info);
     }
     catch
     {
         return false;
     }
 }
Exemple #10
0
        private bool Load_Info(int iid)
        {
            try
            {
                ProductInfo info = null;
                if (iid != 0)
                {
                    info = (new CProduct(CCommon.LANG)).Wcmm_Getinfo(iid);
                    if (info != null)
                    {
                        lstError = new List<Errorobject>();
                        lstError = Form_GetError(lstError, Errortype.Notice, Definephrase.Save_notice, "[" + info.Id + "] " + info.Name, null);
                        Master.Form_ShowError(lstError);
                    }
                }
                if (info == null)
                    info = new ProductInfo();
                chkSaveoption_golist.Checked = info.Id != 0;
                chkSaveoption_golang.Checked = info.Id == 0;

                txtId.Value = info.Id.ToString();
                txtName.Text = info.Name;
                txtCode.Text = info.Code;
                txtIntroduce.Text = info.Introduce;
                txtDescription.Text = info.Description;
                txtPrice.Text = info.Price == 0 ? "" : info.ePrice.ToString();
                txtPricealter.Text = info.Pricealter == 0 ? "" : info.ePricealter.ToString();
                chkAllowcomment.Checked = info.Allowcomment > 0 ? true : false;
                Filepreview.Set(info.Filepreview);
                Displaysetting.Set(info.Iconex, info.Status, info.Orderd, info.Markas);
                Assigntouser.Set_User(info.Username);
                Fileattach.Bind_Files(iid, Webcmm.Id.Product);
                Relatedproduct.Set(info.Relateditem);
                Relatednews.Set(info.Relatednews);

                ddlCid.SelectedValue = info.Cid != 0 ? info.Cid.ToString() : CCommon.Get_QueryNumber(Queryparam.Cid).ToString();
                Categorymulti.Build_Categorymulti(Webcmm.Id.Product, 0, info.Categoryid);
                Categoryattr.Build_Categoryattr(Webcmm.Id.Product, 0, info.Categoryattrid);
                return true;
            }
            catch
            {
                return false;
            }
        }