Exemplo n.º 1
0
        //Delete a province from file
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            labelDisplay.Text = "";
            DAProvince province = new DAProvince();

            province.ProvinceCode       = textBoxPrvCd.Text;
            province.Name               = textBoxName.Text;
            province.CountryCode        = textBoxCntryCd.Text;
            province.TaxCode            = textBoxTaxCd.Text;
            province.TaxRate            = Convert.ToDouble(textBoxTaxRate.Text);
            province.IncludesFederalTax = checkBoxFedTax.Checked;
            try
            {
                province.DADelete();
                UpdateListBoxDisplay();
                textBoxPrvCd.Text      = "";
                textBoxName.Text       = "";
                textBoxCntryCd.Text    = "";
                textBoxTaxCd.Text      = "";
                textBoxTaxRate.Text    = "";
                checkBoxFedTax.Checked = false;
                labelDisplay.Text     += "Province deleted\n";
            }
            catch (Exception ex)
            {
                labelDisplay.Text += ex.Message;
            }
        }
Exemplo n.º 2
0
        //Update list box after deleting or saving province
        private void UpdateListBoxDisplay(DAProvince province = null)
        {
            listBoxDisplay.Items.Clear();

            List <DAProvince> provinceList = new List <DAProvince>();

            if (province != null)
            {
                provinceList = province.DAGetProvinces();

                foreach (DAProvince item in provinceList)
                {
                    listBoxDisplay.Items.Add(item.ProvinceCode);
                }
                listBoxDisplay.SelectedItem = province.ProvinceCode;
            }
            else
            {
                province     = new DAProvince();
                provinceList = province.DAGetProvinces();

                foreach (DAProvince item in provinceList)
                {
                    listBoxDisplay.Items.Add(item.ProvinceCode);
                }
                listBoxDisplay.SelectedIndex = -1;
            }
        }
Exemplo n.º 3
0
    override protected Boolean LoadData()
    {
        try
        {
            // Load Data For Page.
            DAProvince daProvince = new DAProvince();
            daProvince.USP_Province_GetFullID(this.KeyID);
            //
            fProvince.Value          = daProvince.fProvince.ToString();
            fIsAllowShipping.Checked = daProvince.fIsAllowShipping;
            fIsAllowBilling.Checked  = daProvince.fIsAllowBilling;

            //

            // Khi cần enabled cột nào
            //if (this.KeyID > 0)
            //{
            //    if (mode != Act.Clone)
            //        fUserName.Enabled = false;
            //    else
            //        fUserName.Text = "";
            //}
        }
        catch (Exception e)
        {
            ShowErrorMes("Lỗi hệ thống: " + e.ToString());
            return(false);
        }

        return(true);
    }
Exemplo n.º 4
0
    override protected Boolean GetDataComboBox()
    {
        try
        {
            DAOrderStatus daOrderStatus = new DAOrderStatus();
            fOrderStatusID.DataSource = daOrderStatus.USP_OrderStatus_GetDataForComboBox();
            fOrderStatusID.DataBind();

            DAPayment daPayment = new DAPayment();
            fPaymentID.DataSource = daPayment.USP_Payment_GetDataForComboBox();
            fPaymentID.DataBind();

            DAShipping daShipping = new DAShipping();
            fShippingID.DataSource = daShipping.USP_Shipping_GetDataForComboBox();
            fShippingID.DataBind();

            DAProvince daProvinceBilling = new DAProvince();
            fBillProvinceID.DataSource = daProvinceBilling.USP_Province_GetDataForComboBox();
            fBillProvinceID.DataBind();

            DADistrict daDistrictBilling = new DADistrict();
            fBillDistrictID.DataSource = daDistrictBilling.USP_District_GetDataForComboBox_ByProvinceID(int.Parse(fBillProvinceID.SelectedValue));
            fBillDistrictID.DataBind();


            DAProvince daProvinceShipping = new DAProvince();
            fShipProvinceID.DataSource = daProvinceShipping.USP_Province_GetDataForComboBox();
            fShipProvinceID.DataBind();


            DADistrict daDistrictShipping = new DADistrict();
            fShipDistrictID.DataSource = daDistrictShipping.USP_District_GetDataForComboBox_ByProvinceID(int.Parse(fShipProvinceID.SelectedValue));
            fShipDistrictID.DataBind();

            DACustomer daCustomer = new DACustomer();
            fCustomerID.DataSource = daCustomer.USP_Customer_GetDataForComboBox();
            fCustomerID.DataBind();

            DAProvince daProvince = new DAProvince();
            fProvinceID.DataSource = daProvince.USP_Province_GetDataForComboBox();
            fProvinceID.DataBind();

            DACustomerGroup daCustomerGroup = new DACustomerGroup();
            fCustomerGroupID.DataSource = daCustomerGroup.USP_CustomerGroup_GetDataForComboBox();
            fCustomerGroupID.DataBind();


            //LoadCategory();
            return(true);
        }
        catch (Exception ex)
        {
            ShowErrorMes("Lỗi hệ thống: " + ex.Message);
            return(false);
        }
    }
Exemplo n.º 5
0
 override protected int DeleteByID(int pID)
 {
     try
     {
         DAProvince DAProvince = new DAProvince();
         DAProvince.USP_Province_Delete(pID);
         return(1);
     }
     catch { return(0); }
 }
Exemplo n.º 6
0
        //When selectedIndex changes, fill the fields with the info from province selected
        private void listBoxDisplay_SelectedIndexChanged(object sender, EventArgs e)
        {
            DAProvince province = new DAProvince();

            province = province.DAGetByProvinceCode
                           (listBoxDisplay.SelectedItem.ToString());
            textBoxPrvCd.Text      = province.ProvinceCode;
            textBoxName.Text       = province.Name;
            textBoxCntryCd.Text    = province.CountryCode;
            textBoxTaxCd.Text      = province.TaxCode;
            textBoxTaxRate.Text    = province.TaxRate.ToString();
            checkBoxFedTax.Checked = province.IncludesFederalTax;
        }
Exemplo n.º 7
0
    override protected int ExecUpdate()
    {
        // Update with ID = this.ID
        try
        {
            DAProvince DAProvince = CreateObjectFromPage();
            DAProvince.fID = this.KeyID;

            DAProvince.USP_Province_Update();
            return(1);
        }
        catch { return(0); }
    }
Exemplo n.º 8
0
    private DAProvince CreateObjectFromPage()
    {
        // check
        DAProvince daProvince = new DAProvince();

        //
        daProvince.fProvince        = fProvince.Value.Trim();
        daProvince.fIsAllowShipping = fIsAllowShipping.Checked;
        daProvince.fIsAllowBilling  = fIsAllowBilling.Checked;

        //

        return(daProvince);
    }
Exemplo n.º 9
0
    override protected Boolean GetDataComboBox()
    {
        try
        {
            DAProvince daProvince = new DAProvince();
            fProvinceID.DataSource = daProvince.USP_Province_GetDataForComboBox();
            fProvinceID.DataBind();

            return(true);
        }
        catch (Exception ex)
        {
            ShowErrorMes("Lỗi hệ thống: " + ex.Message);
            return(false);
        }
    }
Exemplo n.º 10
0
    override protected int ExecInsert()
    {
        try
        {
            DAProvince DAProvince = CreateObjectFromPage();

            if (this.mode == ActParam.New)
            {
                DAProvince.fID = DAProvince.USP_GetKey();
                this.KeyID     = DAProvince.fID; // --> Update new SessionID for continue edit.
            }
            else
            {
                DAProvince.fID = 0;
            }

            DAProvince.USP_Province_Insert();
            return(1);
        }
        catch { return(0); }
    }
Exemplo n.º 11
0
        //Save a new province, or save an updated province
        private void buttonSave_Click(object sender, EventArgs e)
        {
            DAProvince province = new DAProvince();

            province.ProvinceCode       = textBoxPrvCd.Text;
            province.Name               = textBoxName.Text;
            province.CountryCode        = textBoxCntryCd.Text;
            province.TaxCode            = textBoxTaxCd.Text;
            province.TaxRate            = Convert.ToDouble(textBoxTaxRate.Text);
            province.IncludesFederalTax = checkBoxFedTax.Checked;

            //If the province does not exist on file, create new
            if (province.DAGetByProvinceCode(province.ProvinceCode) == null)
            {
                try
                {
                    province.DAAdd();
                    UpdateListBoxDisplay(province);
                }
                catch (Exception ex)
                {
                    labelDisplay.Text += ex.Message;
                }
            }
            //If province exist on file, update changes
            else
            {
                try
                {
                    province.DAUpdate();
                }
                catch (Exception ex)
                {
                    labelDisplay.Text += ex.Message;
                }
            }
        }