public void Delete(int psf_id)
    {
        ProductSubFormatInfo        info  = GetSubFormatKey(psf_id);
        List <ProductSubFormatInfo> infos = UpdateSorting(info.p_id, info.psf_sorting);

        foreach (ProductSubFormatInfo pdsinfo in infos)
        {
            db.Update(pdsinfo.p_id, pdsinfo.psf_name, pdsinfo.psf_value, pdsinfo.psf_sorting - 1, pdsinfo.psf_id);
        }
        db.Delete(psf_id);
    }
    public List <ProductSubFormatInfo> UpdateSorting(int p_id, int psf_sorting)
    {
        List <ProductSubFormatInfo> infos = new List <ProductSubFormatInfo>();
        IDataReader reader = db.UpdateSubFormatSorting(p_id, psf_sorting).CreateDataReader();

        while (reader.Read())
        {
            infos.Add(ProductSubFormatInfo.Populate(reader));
        }
        return(infos);
    }
    public List <ProductSubFormatInfo> GetFormatWithProduct(int p_id)
    {
        List <ProductSubFormatInfo> infos = new List <ProductSubFormatInfo>();
        IDataReader reader = db.GetFormatWithProduct(p_id).CreateDataReader();

        while (reader.Read())
        {
            infos.Add(ProductSubFormatInfo.Populate(reader));
        }
        return(infos);
    }
    public ProductSubFormatInfo GetSubFormatKey(int psf_id)
    {
        ProductSubFormatInfo info   = new ProductSubFormatInfo();
        IDataReader          reader = db.GetSubFormatKey(psf_id).CreateDataReader();

        if (reader.Read())
        {
            info = ProductSubFormatInfo.Populate(reader);
        }
        return(info);
    }
    public int GetFormatInsertSorting(int p_id)
    {
        int check = 1;
        ProductSubFormatInfo info   = new ProductSubFormatInfo();
        IDataReader          reader = db.GetSubformatInsertSorting(p_id).CreateDataReader();

        if (reader.Read())
        {
            info  = ProductSubFormatInfo.Populate(reader);
            check = info.psf_sorting + 1;
        }
        return(check);
    }
Beispiel #6
0
    protected void btNewFormat_Click(object sender, EventArgs e)
    {
        if (txtNewFormat.Text == "")
        {
            ShowMessage("請輸入規格名稱");
            return;
        }
        ProductSubFormatInfo info = new ProductSubFormatInfo();

        info.p_id        = Tools.GetInt32SafeFromQueryString(this.Page, "id", 0);
        info.psf_name    = txtNewFormat.Text;
        info.psf_sorting = pdsFM.GetFormatInsertSorting(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
        pdsFM.Insert(info);
        rpFormat.DataSource = pdsFM.GetFormatWithProduct(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
        rpFormat.DataBind();
    }
Beispiel #7
0
    private void InsertProductSubFormat(int ProductID)
    {
        ProductSubFormatInfo info = new ProductSubFormatInfo();

        //讀取ItemDataBound
        for (int i = 0; i < rpFormat.Items.Count; i++)
        {
            CheckBox ckbox           = (CheckBox)rpFormat.Items[i].FindControl("ckFormat");
            Label    lbtxtFormatName = (Label)rpFormat.Items[i].FindControl("lbFormat");
            TextBox  txtFormatValue  = (TextBox)rpFormat.Items[i].FindControl("txtFormatValue");
            TextBox  txtSorting      = (TextBox)rpFormat.Items[i].FindControl("txtSorting");
            info.p_id        = ProductID;
            info.psf_name    = lbtxtFormatName.Text;
            info.psf_value   = txtFormatValue.Text;
            info.psf_sorting = Tools.TryParseMethod(txtSorting.Text); //必須驗證
            if (pdsFMBLL.Insert(info) > 0)
            {
                ShowMessage("新增規格成功");
            }
        }
    }
Beispiel #8
0
    protected void rpFormat_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        Label lb2;
        Label lb3;
        int   ClickNowKey   = 0;
        int   RdyChangeKey  = 0;
        int   ClickNowSort  = 0;
        int   RdyChangeSort = 0;

        if (e.CommandName == "Delete")
        {
            Label lb = (Label)e.Item.FindControl("lbFormatID");
            pdsFM.Delete(int.Parse(lb.Text));
        }
        if (e.CommandName == "btnSortUp")
        {
            ClickNowKey  = e.Item.ItemIndex;
            RdyChangeKey = e.Item.ItemIndex - 1;
            if (ClickNowKey > 0)
            {
                lb2 = (Label)rpFormat.Items[ClickNowKey].FindControl("lbFormatID");
                lb3 = (Label)rpFormat.Items[RdyChangeKey].FindControl("lbFormatID");
                ProductSubFormatInfo pdsFMClick  = pdsFM.GetSubFormatKey(int.Parse(lb2.Text));
                ProductSubFormatInfo pdsFMChange = pdsFM.GetSubFormatKey(int.Parse(lb3.Text));
                ClickNowSort            = pdsFMClick.psf_sorting;
                RdyChangeSort           = pdsFMChange.psf_sorting;
                pdsFMClick.psf_sorting  = RdyChangeSort;
                pdsFMChange.psf_sorting = ClickNowSort;
                pdsFM.Update(pdsFMClick);
                pdsFM.Update(pdsFMChange);
            }
            else
            {
                ShowMessage("此項目排序已是第一位");
            }
        }
        if (e.CommandName == "btnSortDown")
        {
            ClickNowKey  = e.Item.ItemIndex;
            RdyChangeKey = e.Item.ItemIndex + 1;
            if (ClickNowKey + 1 < rpFormat.Items.Count)
            {
                lb2 = (Label)rpFormat.Items[ClickNowKey].FindControl("lbFormatID");
                lb3 = (Label)rpFormat.Items[RdyChangeKey].FindControl("lbFormatID");
                ProductSubFormatInfo pdsFMClick  = pdsFM.GetSubFormatKey(int.Parse(lb2.Text));
                ProductSubFormatInfo pdsFMChange = pdsFM.GetSubFormatKey(int.Parse(lb3.Text));
                ClickNowSort            = pdsFMClick.psf_sorting;
                RdyChangeSort           = pdsFMChange.psf_sorting;
                pdsFMClick.psf_sorting  = RdyChangeSort;
                pdsFMChange.psf_sorting = ClickNowSort;
                pdsFM.Update(pdsFMClick);
                pdsFM.Update(pdsFMChange);
            }
            else
            {
                ShowMessage("此項目排序已是最底");
            }
        }
        rpFormat.DataSource = pdsFM.GetFormatWithProduct(Tools.GetInt32SafeFromQueryString(this.Page, "id", 0));
        rpFormat.DataBind();
    }
 public void Update(ProductSubFormatInfo info)
 {
     db.Update(info.p_id, info.psf_name, info.psf_value, info.psf_sorting, info.psf_id);
 }
 public int Insert(ProductSubFormatInfo info)
 {
     return(db.Insert(info.p_id, info.psf_name, info.psf_value, info.psf_sorting));
 }