Exemple #1
0
        public void SaveForm()
        {
            string action, suburb, postcode, estatename;
            int    bedroom, bathroom, storey, brandID, sortOrder, parentHomeID, HomeID, regionID, originalparentHomeID, originaldisplayHomeID, stateID;
            double houseArea, houseAreaSquare, alfrescoArea, alfrescoAreaSquares, garageArea, garageAreaSquares, blocksize;
            double totalArea, totalAreaSquares, minimumBlockWidth, houseLength, houseWidth, garageBays;
            string displayclosedate = "";

            //initialize all blank integer field
            if (txtParentHomeID.Text != "")
            {
                if (txtProductID.Text != "")
                {
                    success           = 1;
                    bedroom           = MetriconCommon.initIntVariables(dropBedrooms.Text.ToString());
                    bathroom          = MetriconCommon.initIntVariables(dropBathrooms.Text.ToString());
                    storey            = MetriconCommon.initIntVariables(dropStoreys.Text.ToString());
                    dropBrand.Enabled = true;
                    brandID           = MetriconCommon.initIntVariables(dropBrand.SelectedValue.ToString());
                    dropBrand.Enabled = false;
                    stateID           = Int32.Parse(dropdownState.SelectedValue.ToString());
                    sortOrder         = MetriconCommon.initIntVariables(txtSortOrder.Text.ToString());
                    HomeID            = MetriconCommon.initIntVariables(txtHomeID.Text.ToString());
                    parentHomeID      = MetriconCommon.initIntVariables(txtParentHomeID.Text.ToString());

                    //regionID = MetriconCommon.initIntVariables(dropRegion.SelectedValue.ToString());
                    originalparentHomeID  = MetriconCommon.initIntVariables(txtOriginalHomeID.Text.ToString());
                    originaldisplayHomeID = MetriconCommon.initIntVariables(txtOriginalDisHomeID.Text.ToString());

                    //initialize all blank decimal field
                    houseArea           = MetriconCommon.initDoubleVariables(txtHouseArea.Text.ToString());
                    houseAreaSquare     = MetriconCommon.initDoubleVariables(txtHouseAreaSquares.Text.ToString());
                    alfrescoArea        = MetriconCommon.initDoubleVariables(txtAlfrescoArea.Text.ToString());
                    alfrescoAreaSquares = MetriconCommon.initDoubleVariables(txtAlfrescoAreaSquares.Text.ToString());
                    garageArea          = MetriconCommon.initDoubleVariables(txtGarageArea.Text.ToString());
                    garageAreaSquares   = MetriconCommon.initDoubleVariables(txtGarageAreaSquares.Text.ToString());
                    totalArea           = MetriconCommon.initDoubleVariables(txtTotalArea.Text.ToString());
                    totalAreaSquares    = MetriconCommon.initDoubleVariables(txtTotalAreaSquares.Text.ToString());
                    minimumBlockWidth   = MetriconCommon.initDoubleVariables(txtMinimumBlockWidth.Text.ToString());
                    houseLength         = MetriconCommon.initDoubleVariables(txtHouseLength.Text.ToString());
                    houseWidth          = MetriconCommon.initDoubleVariables(txtHouseWidth.Text.ToString());
                    garageBays          = MetriconCommon.initDoubleVariables(txtGarageBays.Text.ToString());

                    if (txtclosedate.Text != "")
                    {
                        displayclosedate = dateTimePicker1.Value.ToString("dd/MMM/yyyy");
                    }


                    string sb;
                    try
                    {
                        sb = dropSuburb.SelectedItem.ToString();
                    }
                    catch (Exception ex)
                    {
                        sb = dropSuburb.Text;
                    }

                    try
                    {
                        estatename = dropEstate.SelectedItem.ToString();
                    }
                    catch (Exception ex)
                    {
                        estatename = dropEstate.Text;
                    }

                    if (txtLotAddress.Text == "")
                    {
                        success = 0;
                        MessageBox.Show("Please enter the lot address!");
                        return;
                    }
                    if (sb == "")
                    {
                        suburb   = "";
                        postcode = "";
                        success  = 0;
                        MessageBox.Show("Please select appropriate suburb!");
                        return;
                    }
                    else
                    {
                        suburb   = sb.Substring(0, sb.IndexOf("(") - 1);
                        postcode = sb.Substring(sb.IndexOf("(") + 1, sb.IndexOf(")") - sb.IndexOf("(") - 1);
                    }

                    if (estatename == "")
                    {
                        success = 0;
                        MessageBox.Show("Please select the estate!");
                        return;
                    }


                    try
                    {
                        if (txtBlockSize.Text != "")
                        {
                            blocksize = double.Parse(txtBlockSize.Text);
                        }
                        else
                        {
                            success = 0;
                            MessageBox.Show("Please select appropriate block size!!");
                            return;
                        }
                    }
                    catch
                    {
                        success = 0;
                        MessageBox.Show("Please select appropriate block size!!");
                        return;
                    }
                    //if (radioButton1.Checked)
                    //{
                    //    if (dropSuburb.SelectedValue != null)
                    //    {
                    //        suburb = dropSuburb.SelectedValue.ToString();
                    //    }
                    //    else
                    //    {
                    //        suburb = "";
                    //        success = 0;
                    //        MessageBox.Show("Please select appropriate suburb!!");
                    //    }
                    //}
                    //else
                    //{
                    //    suburb = txtSuburb.Text.ToString();
                    //}

                    if (mode == InputFormMode.New)
                    {
                        action = "NEW";
                    }
                    else
                    {
                        action = "EDIT";
                    }

                    if (suburb != "")
                    {
                        //execute procedure to save data
                        //this.pictureBox1.Visible = true;
                        MetriconCommon.DatabaseManager.ExecuteSQLQuery("AdminAddEditHomeDisplay", new System.Data.SqlClient.SqlParameter[52]
                        {
                            new System.Data.SqlClient.SqlParameter("@HomeID", HomeID)
                            , new System.Data.SqlClient.SqlParameter("@HomePlan", txtHomePlan.Text)
                            , new System.Data.SqlClient.SqlParameter("@HomeFacade", txtHomeFacade.Text)
                            , new System.Data.SqlClient.SqlParameter("@StateID", stateID)
                            , new System.Data.SqlClient.SqlParameter("@BrandID", brandID)
                            , new System.Data.SqlClient.SqlParameter("@ProductID", txtProductID.Text)
                            , new System.Data.SqlClient.SqlParameter("@HouseArea", houseArea)
                            , new System.Data.SqlClient.SqlParameter("@HouseAreaSquares", houseAreaSquare)
                            , new System.Data.SqlClient.SqlParameter("@AlfrescoArea", alfrescoArea)
                            , new System.Data.SqlClient.SqlParameter("@AlfrescoAreaSquares", alfrescoAreaSquares)
                            , new System.Data.SqlClient.SqlParameter("@GarageArea", garageArea)
                            , new System.Data.SqlClient.SqlParameter("@GarageAreaSquares", garageAreaSquares)
                            , new System.Data.SqlClient.SqlParameter("@TotalArea", totalArea)
                            , new System.Data.SqlClient.SqlParameter("@TotalAreaSquares", totalAreaSquares)
                            , new System.Data.SqlClient.SqlParameter("@Min_Block_Width", minimumBlockWidth)
                            , new System.Data.SqlClient.SqlParameter("@HouseLength", houseLength)
                            , new System.Data.SqlClient.SqlParameter("@HouseWidth", houseWidth)
                            , new System.Data.SqlClient.SqlParameter("@GarageBays", garageBays)
                            , new System.Data.SqlClient.SqlParameter("@Bedrooms", bedroom)
                            , new System.Data.SqlClient.SqlParameter("@Bathrooms", bathroom)
                            , new System.Data.SqlClient.SqlParameter("@Stories", storey)
                            , new System.Data.SqlClient.SqlParameter("@DESC", txtDesc.Text)
                            , new System.Data.SqlClient.SqlParameter("@EDESC", txtEdesc.Text)
                            , new System.Data.SqlClient.SqlParameter("@CSTCTR", txtCstctr.Text)
                            , new System.Data.SqlClient.SqlParameter("@SUOFM", txtSuofm.Text)
                            , new System.Data.SqlClient.SqlParameter("@PUOFM", txtPuofm.Text)
                            , new System.Data.SqlClient.SqlParameter("@PRDCAT", txtPrdcat.Text)
                            , new System.Data.SqlClient.SqlParameter("@TAXCD", txtTaxcd.Text)
                            , new System.Data.SqlClient.SqlParameter("@PRDSOP", txtPrdsop.Text)
                            , new System.Data.SqlClient.SqlParameter("@USRDEF", txtUsrdef.Text)
                            , new System.Data.SqlClient.SqlParameter("@LDESC", txtLdesc.Text)
                            , new System.Data.SqlClient.SqlParameter("@BRAND", txtBrand.Text)
                            , new System.Data.SqlClient.SqlParameter("@SPECYEAR", txtSpecyear.Text)
                            , new System.Data.SqlClient.SqlParameter("@HOUSECODE", txtHousecode.Text)
                            , new System.Data.SqlClient.SqlParameter("@HOUSESIZE", txtHousesize.Text)
                            , new System.Data.SqlClient.SqlParameter("@HOUSEFACADE", txtHousefacade.Text)
                            , new System.Data.SqlClient.SqlParameter("@STOREY", txtStorey.Text)
                            , new System.Data.SqlClient.SqlParameter("@MARK", txtMark.Text)
                            , new System.Data.SqlClient.SqlParameter("@SortOrder", txtSortOrder.Text)
                            , new System.Data.SqlClient.SqlParameter("@CreatedBy", MetriconCommon.UserCode)
                            , new System.Data.SqlClient.SqlParameter("@Active", chkActive.Checked)
                            , new System.Data.SqlClient.SqlParameter("@draft", chkDraft.Checked)
                            , new System.Data.SqlClient.SqlParameter("@parentHomeID", parentHomeID)
                            , new System.Data.SqlClient.SqlParameter("@action", action)
                            , new System.Data.SqlClient.SqlParameter("@lotAddress", txtLotAddress.Text)
                            , new System.Data.SqlClient.SqlParameter("@suburb", suburb)
                            , new System.Data.SqlClient.SqlParameter("@postcode", postcode)
                            , new System.Data.SqlClient.SqlParameter("@blocksize", blocksize)
                            , new System.Data.SqlClient.SqlParameter("@originalParentHomeID", originalparentHomeID)
                            , new System.Data.SqlClient.SqlParameter("@originalDisplayHomeID", originaldisplayHomeID)
                            , new System.Data.SqlClient.SqlParameter("@estatename", estatename)
                            , new System.Data.SqlClient.SqlParameter("@displayclosedate", displayclosedate)
                        }
                                                                       );
                        //get the id of the new house that was inserted
                        //DataSet dsTemp = MetriconCommon.DatabaseManager.ExecuteSQLQuery("select max(homeid) as homeid from home");

                        //this.txtHomeID.Text = dsTemp.Tables[0].Rows.Count == 1 ? dsTemp.Tables[0].Rows[0]["homeid"].ToString() : "";
                        if (action == "NEW")
                        {
                            DataSet dsTemp = MetriconCommon.DatabaseManager.ExecuteSQLQuery("select max(homeid) as homeid from home");
                            this.txtHomeID.Text = dsTemp.Tables[0].Rows.Count == 1 ? dsTemp.Tables[0].Rows[0]["homeid"].ToString() : "";
                        }
                        this.pictureBox1.Visible = false;
                    }
                }
                else
                {
                    success = 0;
                    MessageBox.Show("Please select a facade!", "Missing Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                success = 0;
                MessageBox.Show("Please select a parent home!", "Missing Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        private void savePromotion()
        {
            int    promID, promTypeID, active, published, stories, sortorder, brandID, goAhead;;
            double promCost, promBudget;
            string tempdate, action;

            tempdate = "";
            goAhead  = 1;

            if (txtBaseProductID.Text.ToString() != "")
            {
                promID     = MetriconCommon.initIntVariables(txtPromID.Text.ToString());
                promTypeID = MetriconCommon.initIntVariables(dropPromType.SelectedValue.ToString());

                brandID   = MetriconCommon.initIntVariables(dropBrand.SelectedValue.ToString());
                stories   = MetriconCommon.initIntVariables(txtStories.Text.ToString());
                sortorder = MetriconCommon.initIntVariables(txtSortOrder.Text.ToString());

                if (this.chkActive.Checked)
                {
                    active = 1;
                }
                else
                {
                    active = 0;
                }
                if (this.chkPublished.Checked)
                {
                    goAhead   = checkPAG();
                    published = 1;
                    if (txtEffectiveDate.Text == "")
                    {
                        MessageBox.Show("Please enter an effective date!");
                    }
                    else
                    {
                        try
                        {
                            DateTime tempdate3 = DateTime.Parse(txtEffectiveDate.Text.ToString());
                            tempdate = tempdate3.ToString("dd/MMM/yyyy");
                        }
                        catch (FormatException ex)
                        {
                            MessageBox.Show("Please enter a valid effective date! " + ex.ToString());
                        }
                    }
                }
                else
                {
                    published = 0;
                }

                if (goAhead == 1)
                {
                    promCost   = MetriconCommon.initDoubleVariables(txtPromCost.Text.ToString());
                    promBudget = MetriconCommon.initDoubleVariables(txtPromBudget.Text.ToString());

                    if (txtPromID.Text == "")
                    {
                        action = "NEW";
                    }
                    else
                    {
                        action = "EDIT";
                    }

                    // insert data to tabel
                    MetriconCommon.DatabaseManager.ExecuteSQLQuery("AdminAddEditPromotion", new System.Data.SqlClient.SqlParameter[15] {
                        new System.Data.SqlClient.SqlParameter("@promID", promID)
                        , new System.Data.SqlClient.SqlParameter("@promTypeID", promTypeID)
                        , new System.Data.SqlClient.SqlParameter("@promname", txtPromName.Text)
                        , new System.Data.SqlClient.SqlParameter("@baseProductID", txtBaseProductID.Text)
                        , new System.Data.SqlClient.SqlParameter("@budgetProductID", txtBudgetProductID.Text)
                        , new System.Data.SqlClient.SqlParameter("@promCost", promCost)
                        , new System.Data.SqlClient.SqlParameter("@promBudget", promBudget)
                        , new System.Data.SqlClient.SqlParameter("@published", published)
                        , new System.Data.SqlClient.SqlParameter("@sortorder", sortorder)
                        , new System.Data.SqlClient.SqlParameter("@brandID", brandID)
                        , new System.Data.SqlClient.SqlParameter("@stories", stories)
                        , new System.Data.SqlClient.SqlParameter("@effectiveDate", tempdate)
                        , new System.Data.SqlClient.SqlParameter("@active", active)
                        , new System.Data.SqlClient.SqlParameter("@CreatedBy", MetriconCommon.UserCode)
                        , new System.Data.SqlClient.SqlParameter("@action", action)
                    }
                                                                   );

                    // get new promotion ID and show on screen
                    if (action == "NEW")
                    {
                        DataSet dsTemp = MetriconCommon.DatabaseManager.ExecuteSQLQuery("select max(promotionID) as promID from promotion");
                        this.txtPromID.Text = dsTemp.Tables[0].Rows.Count == 1 ? dsTemp.Tables[0].Rows[0]["promID"].ToString() : "";

                        this.btnAddPAG.Enabled = true;
                    }
                    MessageBox.Show("Data saved successfully!");
                }
                else
                {
                    MessageBox.Show("No PAG in current promotion! Please add PAG to this promotion and publish again!");
                }
            }
            else
            {
                MessageBox.Show("Please enter a base product ID!");
            }
        }