public object Delete(int id, string category_code)
        {
            string token = Request.Headers.Authorization == null ? "" : Request.Headers.Authorization.ToString();

            Logger.Info(Request.RequestUri + "  ||  Method: " + Request.Method, Request.Headers.ToString(), JsonConvert.SerializeObject(id), Level.INFO);

            ResponseDTO Response            = new ResponseDTO();
            ResponseDTO ResponseStore       = new ResponseDTO();
            ResponseDTO ResponseLegislation = new ResponseDTO();
            ErrorDTO    ErrorResponse       = new ErrorDTO();
            CategoryDTO UserResponse        = new CategoryDTO();

            ResponseStore       = StoreBUS.GetAllStore("", category_code, "", "", 1, 100);
            ResponseLegislation = LegislationBUS.GetAllLegislation("", "", category_code, 1, 100);

            if (ResponseStore.Data == null && ResponseLegislation.Data == null)
            {
                Response = CategoryBUS.DeleteCategory(id);
            }
            else
            {
                ErrorResponse.Code    = 400;
                ErrorResponse.Message = "Industry being used";
                Response.Error        = ErrorResponse;
            }

            return(Response);
        }
 public static bool UpdateCate(Category c)
 {
     if (CategoryBUS.UpdateCate(c) == true)
     {
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        private void LoadComboBox()
        {
            List <Category> list = new CategoryBUS().GetCategories();

            comboBox1.DataSource    = list;
            comboBox1.DisplayMember = "CategoryName";
            comboBox1.ValueMember   = "CategoryID";
        }
 public static bool DelCate(int idCate)
 {
     if (CategoryBUS.DelCate(idCate) == true)
     {
         return(true);
     }
     return(false);
 }
 public static bool CreateCate(Category cate)
 {
     if (CategoryBUS.CreateCate(cate) == true)
     {
         return(true);
     }
     return(false);
 }
Beispiel #6
0
 // Load database to view
 private void initLoad()
 {
     productTBBindingSource.DataSource = ProductBUS.getAll();
     categoryBindingSource.DataSource  = CategoryBUS.getAll();
     brandBindingSource.DataSource     = BrandBUS.getAll();
     productBindingSource.DataSource   = new Product();
     dgvProduct.ClearSelection();
 }
Beispiel #7
0
        //Open category form
        private void btnAddCate_Click(object sender, EventArgs e)
        {
            frmCategory _frmCate = new frmCategory();

            if (_frmCate.ShowDialog() == DialogResult.Cancel)
            {
                categoryBindingSource.DataSource = CategoryBUS.getAll();
            }
        }
Beispiel #8
0
        //Auto complete the unit price unit base on box
        private void txtPBox_KeyUp(object sender, KeyEventArgs e)
        {
            int input;

            if (int.TryParse(txtPBox.Text, out input))
            {
                Category _cate  = CategoryBUS.getById((int)cboCate.SelectedValue);
                int?     output = (input + _cate.Unit - 1) / _cate.Unit;
                txtPUnit.Text = output.ToString();
            }
        }
        public object Get(string name = "", string title = "", string code = "")
        {
            string token = Request.Headers.Authorization == null ? "" : Request.Headers.Authorization.ToString();

            Logger.Info(Request.RequestUri + "  ||  Method: " + Request.Method, Request.Headers.ToString(), null, Level.INFO);

            ResponseDTO Response = new ResponseDTO();

            Response = CategoryBUS.GetAllCategory(name, title, code);

            return(Response);
        }
        public object UpdateCategory([FromBody] CategoryRequestDTO categoryData)
        {
            string token = Request.Headers.Authorization == null ? "" : Request.Headers.Authorization.ToString();

            Logger.Info(Request.RequestUri + "  ||  Method: " + Request.Method, Request.Headers.ToString(), JsonConvert.SerializeObject(categoryData), Level.INFO);

            ResponseDTO Response      = new ResponseDTO();
            ErrorDTO    ErrorResponse = new ErrorDTO();
            CategoryDTO UserResponse  = new CategoryDTO();

            Response = CategoryBUS.AddOrUpdateCategory(categoryData);


            return(Response);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Category c = new Category();

            c.CategoryID   = int.Parse(textBox1.Text);
            c.CategoryName = textBox2.Text;
            Boolean success = new CategoryBUS().InsertCategory(c);

            if (!success)
            {
                MessageBox.Show("Can not insert " + textBox1.Text, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Successful", "Success",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                textBox1.Text = "";
                textBox2.Text = "";
            }
        }
Beispiel #12
0
 private void frmCategory_Load(object sender, EventArgs e)
 {
     categoryTBBindingSource.DataSource = CategoryBUS.getAll();
     categoryBindingSource.DataSource   = new Category();
 }
Beispiel #13
0
    protected void getRegisterSendList()
    {
        try
        {
            cateBUs = new CategoryBUS();
            srBUS = new SendRegisterBUS();
            srdBus = new SendRegisterDetailBUS();
            mailConfigBus = new MailConfigBUS();
            mailGroupBus = new MailGroupBUS();
            sendContentBus = new SendContentBUS();
            dsgBus = new DetailGroupBUS();
            UserLoginDTO userLogin = getUserLogin();
            DataTable tblSendRegister = new DataTable();
            if (userLogin.DepartmentId == 1)
            {
                tblSendRegister = srBUS.GetAll();
            }
            else
            {
                tblSendRegister = srBUS.GetAll(userLogin.UserId);
            }
            if (tblSendRegister.Rows.Count > 0)
            {
                dlWaitSend.DataSource = tblSendRegister;
                dlWaitSend.DataBind();
                for (int i = 0; i < tblSendRegister.Rows.Count; i++)
                {
                    try
                    {

                        DataRow row = tblSendRegister.Rows[i];
                        int Sendtype = int.Parse(row["Sendtype"].ToString());
                        HiddenField hdfId = (HiddenField)dlWaitSend.Items[i].FindControl("hdfId");
                        hdfId.Value = row["Id"].ToString();
                        int contentId = int.Parse(row["SendContentId"].ToString());
                        //DataTable tblContent = sendContentBus.GetByID(contentId);
                        Label lblSubject = (Label)dlWaitSend.Items[i].FindControl("lblSubject");
                        //if (tblContent.Rows.Count > 0)
                        //{
                        //    lblSubject.Text = tblContent.Rows[0]["Subject"].ToString();
                        //}
                        //else
                        lblSubject.Text = row["Subject"] + "";

                        int mailConfig = int.Parse(row["MailConfigID"].ToString());
                        DataTable tblMailConfig = mailConfigBus.GetByID(mailConfig);
                        if (tblMailConfig.Rows.Count > 0)
                        {
                            Label lblMailConfig = (Label)dlWaitSend.Items[i].FindControl("lblMailConfig");
                            lblMailConfig.Text = tblMailConfig.Rows[0]["Email"].ToString();
                        }
                        int groupTo = int.Parse(row["GroupTo"].ToString());
                        if (groupTo == -3)
                        {
                            Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo");
                            lblGroupTo.Text = "Tất cả khách hàng";
                        }
                        else if (groupTo == -2)
                        {
                            Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo");
                            lblGroupTo.Text = "Nhóm mua nhiều lần";
                        }
                        else if (groupTo == -1)
                        {
                            Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo");
                            lblGroupTo.Text = "Nhóm mua lần đầu";
                        }
                        else
                        {
                            DataTable tblGroupTo = new DataTable();
                            if (Sendtype == 1)
                            {
                                tblGroupTo = mailGroupBus.GetByID(groupTo);

                                if (tblGroupTo.Rows.Count > 0)
                                {
                                    Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo");
                                    lblGroupTo.Text = tblGroupTo.Rows[0]["Name"].ToString();
                                }
                            }
                            else
                            {
                                tblGroupTo = cateBUs.GetByID(groupTo);
                                if (tblGroupTo.Rows.Count > 0)
                                {
                                    Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo");
                                    lblGroupTo.Text = tblGroupTo.Rows[0]["Title"].ToString();
                                }
                            }

                        }

                        Label lblStartDate = (Label)dlWaitSend.Items[i].FindControl("lblStartDate");
                        lblStartDate.Text = row["StartDate"].ToString();

                        Label lblEndDate = (Label)dlWaitSend.Items[i].FindControl("lblEndDate");

                        int status = int.Parse(row["Status"].ToString());

                        Panel panel = (Panel)dlWaitSend.Items[i].FindControl("Panel1");
                        TextBox progressbar = (TextBox)dlWaitSend.Items[i].FindControl("progressbar");
                        LinkButton lbtDetail = (LinkButton)dlWaitSend.Items[i].FindControl("lbtDetail");

                        //get list detail
                        DataTable listDetail = srdBus.GetByID(int.Parse(row["Id"].ToString()));
                        int hasSend = 0, sumSend = dsgBus.GetByID(groupTo).Rows.Count;
                        for (int k = 0; k < listDetail.Rows.Count; k++)
                        {
                            hasSend++;
                        }

                        //calc percent has send
                        int percent = 0;
                        if (sumSend != 0)
                        {
                            percent = (hasSend * 100) / sumSend;
                        }

                        if (status == 0)
                        {
                            //display process bar
                            panel.Visible = true;
                            progressbar.BackColor = System.Drawing.Color.Cornsilk;
                            progressbar.Width = percent + 20;
                            progressbar.Text = percent + "%";

                            lbtDetail.Visible = false;
                            lbtDetail.Text = "";
                            lblEndDate.Text = "Chưa xác định ";
                        }
                        else
                        {
                            //hidden process bar
                            panel.Visible = false;
                            lbtDetail.Text = "Xem chi tiết";
                            lbtDetail.PostBackUrl = "reportSend.aspx?campaign-id=" + row["Id"].ToString();
                            lblEndDate.Text = row["EndDate"].ToString();
                        }

                        LinkButton lbtDelete = (LinkButton)dlWaitSend.Items[i].FindControl("lbtDelete");
                        lbtDelete.CommandArgument = row["Id"].ToString();
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }

        }
        catch (Exception)
        {

        }
    }
 public static List <Category> GetCbbEditByIDCate(int idCate)
 {
     return(CategoryBUS.GetCbbEditByIDCate(idCate));
 }
Beispiel #15
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     CategoryBUS.update(categoryBindingSource.Current as Category);
     categoryTBBindingSource.DataSource = CategoryBUS.getAll();
     categoryBindingSource.DataSource   = new Category();
 }
 public static Category GetCateByID(int idCate)
 {
     return(CategoryBUS.GetCateByID(idCate));
 }
 public static List <Category> GetAllCate()
 {
     return(CategoryBUS.GetAllCate());
 }