示例#1
0
    protected void updateButton_Click(object sender, EventArgs e)
    {
        string strName  = TypeName_edit.Text.ToString();
        string strState = State_edit.Text.ToString();
        string strDesc  = Description_edit.Text.ToString();

        ProductsType pb = new ProductsType();

        pb.TypeName    = strName;
        pb.Description = strDesc;
        pb.State       = strState;
        pb.TypeID      = int.Parse(TypeID.Text.ToString());

        if (Leyp.SQLServerDAL.Factory.getProductsTypeDAL().updateProductsType(pb))
        {
            addSystemLog("更新商品类型:" + strName);
            HyperLink1.Visible = true;
            editPanel.Visible  = false;
            viewPanel.Visible  = false;
        }
        else
        {
            HyperLink1.Text    = "添加失败!可能是名称重复了!你可以返回重新试试";
            HyperLink1.Visible = true;
            editPanel.Visible  = false;
            viewPanel.Visible  = false;
        }
    }
 public void SetDiscount(ProductsType productType, double discountProcent)
 {
     if (discountProcent > 0 && discountProcent < 100)
     {
         listOfTypeProductsDiscount.Add(productType, discountProcent);
     }
 }
示例#3
0
        public async Task <bool> EditProdyctTypeAsync(ProductsType productsType, string oldHEXColor, int olpParentProductTypeId)
        {
            bool result;

            if (olpParentProductTypeId == 1 && productsType.ParentProductTypeId != 1)
            {
                result = await _fcdStoreContext.EditParentProductTypeToNoParent(productsType);
            }
            else
            {
                if (olpParentProductTypeId != 1 && (productsType.ParentProductTypeId == 1 || productsType.ParentProductTypeId == 2))
                {
                    result = await _fcdStoreContext.EditProductTypeToParentProductType(productsType);
                }
                else
                {
                    result = await _fcdStoreContext.EditProductType(productsType);
                }
            }
            if (result)
            {
                _builderBackColorCSS.RefreshCSS(oldHEXColor, productsType.HexColor);
                _cacheService.Remove("ProductType");
                _cacheService.Remove("Product");
                return(true);
            }
            return(false);
        }
示例#4
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (this.TextBox1.Text != null)
     {
         ProductsType s = new ProductsType();
         s.TypeName    = this.TextBox1.Text;
         s.Description = this.TextBox2.Text;
         //s.State = this.DropDownList2.Text;
         if (this.DropDownList1.Text == "正常")
         {
             s.State = "Y";
         }
         else
         {
             s.State = "N";
         }
         int rows = ProductsTypeManager.ProductsTypeInsert(s);
         if (rows > 0)
         {
             Response.Write("<script>alert('添加成功!');</script>");
             this.TextBox1.Text      = "";
             this.TextBox2.Text      = "";
             this.DropDownList1.Text = "正常";
         }
         else
         {
             Response.Write("<script>alert('添加失败!');</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('类型名称不能为空!');</script>");
     }
 }
示例#5
0
    protected void submit_Click(object sender, EventArgs e)
    {
        string strName  = TypeName_New.Text.ToString();
        string strState = State_new.Text.ToString();
        string strDesc  = Description_new.Text.ToString();

        ProductsType pb = new ProductsType();

        pb.TypeName    = strName;
        pb.Description = strDesc;
        pb.State       = strState;

        if (Leyp.SQLServerDAL.Factory.getProductsTypeDAL().insertNewProductsType(pb))
        {
            addSystemLog("新添商品类型:" + strName);
            HyperLink1.Visible = true;
            viewPanel.Visible  = false;
        }
        else
        {
            HyperLink1.Text    = "添加失败!可能是名称重复了!你可以返回重新试试";
            HyperLink1.Visible = true;
            viewPanel.Visible  = false;
        }
    }
示例#6
0
    /// <summary>
    /// 初始化
    /// </summary>
    public void DataBand()
    {
        string action = Request.QueryString["action"];

        if (action == null)
        {
            CollectionPager1.DataSource    = Leyp.SQLServerDAL.Factory.getProductsTypeDAL().getAllProductsType();//BLL项目中List数据源
            CollectionPager1.BindToControl = GridView1;
            GridView1.DataSource           = CollectionPager1.DataSourcePaged;
            editPanel.Visible = false;
        }
        else if (action.Equals("edit"))
        {
            int typeID = 0;
            try
            {
                typeID = int.Parse(Request.QueryString["TypeID"].ToString());
            }
            catch
            {
                Response.Write("参数有误");
                Response.End();
            }

            ProductsType pb = new ProductsType();
            pb = Leyp.SQLServerDAL.Factory.getProductsTypeDAL().getByTypeID(typeID);

            TypeName_edit.Text    = pb.TypeName;
            TypeID.Text           = pb.TypeID.ToString();//保存编辑ID
            Description_edit.Text = pb.Description;
            State_edit.Items.FindByValue(pb.State.ToString()).Selected = true;
            editPanel.Visible = true;
            viewPanel.Visible = false;
        }
        else if (action.Equals("del"))
        {
            int typeID = 0;
            try
            {
                typeID = int.Parse(Request.QueryString["TypeID"].ToString());
            }
            catch
            {
                Response.Write("参数有误");
                Response.End();
            }

            if (Leyp.SQLServerDAL.Factory.getProductsTypeDAL().deleteByTypeID(typeID))
            {
                Response.Write("删除成功!");
                Response.End();
            }
            else
            {
                Response.Write("失败!可能该类型已经在使用中");
                Response.End();
            }
        }
    }
示例#7
0
 public DiscountProduct(string productName, ProductsType productType, double coast, double discountProcent = 0) : base(productName, productType, coast)
 {
     if (discountProcent > 0 && discountProcent < 100)
     {
         Discount   = 1.0 - discountProcent / 100.0;
         this.Cost *= Discount;
     }
 }
示例#8
0
        public static int ProductsTypeUpdate(ProductsType s)
        {
            Database db   = DatabaseFactory.CreateDatabase("Constr");
            string   sql  = string.Format("update t_ProductsType set TypeName='{0}' ,  Description='{1}' ,  State='{2}' where TypeID='{3}'", s.TypeName, s.Description, s.State, s.TypeID);
            int      rows = db.ExecuteNonQuery(CommandType.Text, sql);

            return(rows);
        }
示例#9
0
        public static int ProductsTypeInsert(ProductsType s)
        {
            Database db   = DatabaseFactory.CreateDatabase("Constr");
            string   sql  = string.Format("insert into t_ProductsType values('{0}','{1}','{2}')", s.TypeName, s.State, s.Description);
            int      rows = db.ExecuteNonQuery(CommandType.Text, sql);

            return(rows);
        }
示例#10
0
        public static string GetAtawControlUnitsProductValue(string fControlUnitID, ProductsType databaseType, string key)
        {
            string productName = databaseType.ToString();
            var    database    = AtawAppContext.Current.DBConfigXml.Databases.Where(a => a.IsDefault).FirstOrDefault();

            AtawDebug.AssertArgumentNull(database, "默认的数据库配置不能为空", AtawAppContext.Current);
            string strDefaultConnstring = database.ConnectionString;

            if (fControlUnitID.IsEmpty())
            {
                return(strDefaultConnstring);
            }

            var xml   = AtawAppContext.Current.ProductsXml.ControlUnits;
            var cList = xml.Where(a => a.FControlUnitID == fControlUnitID);

            //IList<ControlUnitItemInfo> m = q.AsQueryable<ControlUnitItemInfo>().ToList();
            if (cList.Count() == 0)
            {
                return(strDefaultConnstring);
            }

            string va = "";

            foreach (var item in cList)
            {
                if (!string.IsNullOrEmpty(va))
                {
                    break;
                }
                foreach (var item2 in item.Products)
                {
                    if (item2.Name == productName && item2.Key == key)
                    {
                        va = item2.Value;
                        if (key == "DB")
                        {
                            va = GetAtawDatabaseValue(va); //返回数据库的字符串
                        }
                        break;
                    }
                }
            }
            if (!string.IsNullOrEmpty(va))
            {
                return(va);
            }
            else
            {
                return(strDefaultConnstring);
            }
            //}
            //catch (Exception)
            //{
            //    return strDefaultConnstring;
            //}
        }
示例#11
0
        public bool insertNewProductsType(ProductsType pt)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@TypeName", SqlDbType.NVarChar), new SqlParameter("@State", SqlDbType.NChar), new SqlParameter("@Description", SqlDbType.NVarChar) };
            parameters[0].Value = pt.TypeName;
            parameters[1].Value = pt.State;
            parameters[2].Value = pt.Description;
            SQLHelper.RunProcedure("p_ProductsType_InsertNew", parameters, out rowsAffected);
            return(1 == rowsAffected);
        }
示例#12
0
 public async Task <IActionResult> DeleteProductsTypes(ProductsType productsType)
 {
     if (await _dataProcessingConveyor.DeleteProductTypeAsync(productsType))
     {
         return(RedirectToAction("ProductsTypesView"));
     }
     else
     {
         return(NotFound());
     }
 }
示例#13
0
        public async Task <bool> AddProductsTypeAsync(ProductsType productsType)
        {
            bool result = await _fcdStoreContext.AddProductsTypeAsync(productsType);

            if (result)
            {
                _builderBackColorCSS.AddNewCSS(productsType.HexColor);
                _cacheService.Remove("ProductType");
                return(true);
            }
            return(false);
        }
示例#14
0
        public async Task <bool> DeleteProductTypeAsync(ProductsType productsType)
        {
            bool result = await _fcdStoreContext.DeleteProductTypeAsync(productsType);

            if (result)
            {
                _cacheService.Remove("ProductType");
                _cacheService.Remove("Product");
                return(true);
            }
            return(false);
        }
示例#15
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     if (context.Request["TypeName"] != null)
     {
         ProductsType s = new ProductsType();
         s.TypeID      = Convert.ToInt32(context.Request["TypeID"]);
         s.TypeName    = context.Request["TypeName"];
         s.State       = context.Request["State"];
         s.Description = context.Request["Description"];
         context.Response.Write(ProductsTypeManager.ProductsTypeUpdate(s) > 0);
     }
 }
示例#16
0
 public async Task <IActionResult> NewProductsTypes(ProductsType productsType)
 {
     if (ModelState.IsValid)
     {
         if (await _dataProcessingConveyor.AddProductsTypeAsync(productsType))
         {
             return(RedirectToAction("ProductsTypesView"));
         }
     }
     else
     {
         View(productsType);
     }
     return(NotFound());
 }
示例#17
0
        public static List <ProductsType> ProductsTypeDrop()
        {
            Database            db  = DatabaseFactory.CreateDatabase("Constr");
            string              sql = string.Format("select  * from t_ProductsType");
            DataSet             ds  = db.ExecuteDataSet(CommandType.Text, sql);
            List <ProductsType> ll  = new List <ProductsType>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ProductsType sh = new ProductsType();
                sh.TypeID   = Convert.ToInt32(item["TypeID"].ToString());
                sh.TypeName = item["TypeName"].ToString();
                ll.Add(sh);
            }
            return(ll);
        }
示例#18
0
 public async Task <IActionResult> EditProductsTypes(ProductsType productsType, string oldHEXColor, int olpParentProductTypeId)
 {
     if (ModelState.IsValid)
     {
         if (await _dataProcessingConveyor.EditProdyctTypeAsync(productsType: productsType,
                                                                oldHEXColor: oldHEXColor,
                                                                olpParentProductTypeId: olpParentProductTypeId))
         {
             return(RedirectToAction("ProductsTypesView"));
         }
         else
         {
             return(NotFound());
         }
     }
     return(View(productsType));
 }
示例#19
0
        public static List <ProductsType> ProductsTypeID(int id)
        {
            Database            db  = DatabaseFactory.CreateDatabase("Constr");
            string              sql = string.Format("select * from t_ProductsType where TypeID='{0}'", id);
            DataSet             ds  = db.ExecuteDataSet(CommandType.Text, sql);
            List <ProductsType> ll  = new List <ProductsType>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ProductsType sh = new ProductsType();
                sh.TypeName    = item["TypeName"].ToString();
                sh.State       = item["State"].ToString();
                sh.Description = item["Description"].ToString();
                ll.Add(sh);
            }
            return(ll);
        }
示例#20
0
        public ProductsType getByTypeID(int TypeID)
        {
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@TypeID", SqlDbType.Int) };
            parameters[0].Value = TypeID;
            ProductsType  type   = new ProductsType();
            SqlDataReader reader = SQLHelper.RunProcedure("p_ProductsType_GetByTypeID", parameters);

            if (reader.Read())
            {
                type.TypeID      = reader.GetInt32(reader.GetOrdinal("TypeID"));
                type.TypeName    = reader.GetString(reader.GetOrdinal("TypeName"));
                type.State       = reader.GetString(reader.GetOrdinal("State"));
                type.Description = reader.GetString(reader.GetOrdinal("Description"));
            }
            reader.Close();
            return(type);
        }
示例#21
0
        public static List <ProductsType> ProductsTypeALL(int index, int rows)
        {
            Database            db  = DatabaseFactory.CreateDatabase("Constr");
            string              sql = string.Format("select top {0} * from t_ProductsType where TypeID not in(select top {1} TypeID from t_ProductsType)", index, index * (rows - 1));
            DataSet             ds  = db.ExecuteDataSet(CommandType.Text, sql);
            List <ProductsType> ll  = new List <ProductsType>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ProductsType sh = new ProductsType();
                sh.TypeID      = Convert.ToInt32(item["TypeID"].ToString());
                sh.TypeName    = item["TypeName"].ToString();
                sh.State       = item["State"].ToString();
                sh.Description = item["Description"].ToString();
                ll.Add(sh);
            }
            return(ll);
        }
示例#22
0
        public List <ProductsType> getAllProductsTypeCanUser()
        {
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@sign", SqlDbType.Int) };
            parameters[0].Value = 1;
            List <ProductsType> list   = new List <ProductsType>();
            SqlDataReader       reader = SQLHelper.RunProcedure("p_ProductsType_GetAll", parameters);

            while (reader.Read())
            {
                ProductsType item = new ProductsType();
                item.TypeID      = reader.GetInt32(reader.GetOrdinal("TypeID"));
                item.TypeName    = reader.GetString(reader.GetOrdinal("TypeName"));
                item.State       = reader.GetString(reader.GetOrdinal("State"));
                item.Description = reader.GetString(reader.GetOrdinal("Description"));
                list.Add(item);
            }
            reader.Close();
            return(list);
        }
示例#23
0
 public static int ProductsTypeUpdate(ProductsType s)
 {
     return(ProductsTypeService.ProductsTypeUpdate(s));
 }
示例#24
0
 public static int ProductsTypeInsert(ProductsType s)
 {
     return(ProductsTypeService.ProductsTypeInsert(s));
 }
示例#25
0
 public Product(string productName, ProductsType productType, double cost)
 {
     ProductType = productType;
     Cost        = cost;
     ProductName = productName;
 }
示例#26
0
 public ProductsItemStock(ProductsType type, int numberOfUnits)
 {
     _type          = type;
     _numberOfUnits = numberOfUnits;
 }
示例#27
0
 public ProductsItemStock()
 {
     _type          = ProductsType.None;
     _numberOfUnits = 0;
 }