示例#1
0
        private void Setup_form()
        {
            using (Organisation_branch_ds.sp_select_organisation_branch_with_org_detailsDataTable dttable_orgbranch =
                       Organisation_branch_ds.Select_organisation_branch_with_org_details(_orgbranch_id))
            {
                if (dttable_orgbranch.Rows.Count == 0)
                {
                    MessageBox.Show("Invalid organisation ID!", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }

                _org_id           = dttable_orgbranch[0].organisation;
                txt_name.Text     = dttable_orgbranch[0].name;
                txt_ic_reg.Text   = dttable_orgbranch[0].registration_no;
                txt_address.Text  = dttable_orgbranch[0].address;
                txt_city.Text     = dttable_orgbranch[0].city;
                txt_state.Text    = dttable_orgbranch[0].state;
                txt_postcode.Text = dttable_orgbranch[0].postcode;
                txt_country.Text  = dttable_orgbranch[0].country_name;
                link_lbl_url.Text = dttable_orgbranch[0].url;
            }
            grd_contact.DataSource = null;
            grd_contact.DataSource = Organisation_contact_ds.Select_organisation_contact(_org_id);
            grd_contact.AutoResizeColumns();
        }
示例#2
0
        private void Setup_form_org()
        {
            lbl_ic_reg.Text = "Registration no.:";
            split_cont_person_org.Panel1Collapsed = true;

            Organisation_branch_ds.sp_select_organisation_branch_with_org_detailsDataTable dttable_branch =
                Organisation_branch_ds.Select_organisation_branch_with_org_details(_person_orgbranch_id);

            if (dttable_branch.Rows.Count > 0)
            {
                txt_name.Text     = dttable_branch[0].branch_name;
                txt_ic_reg.Text   = dttable_branch[0].registration_no;
                txt_type.Text     = dttable_branch[0].organisation_type_description;
                txt_address.Text  = dttable_branch[0].address;
                txt_city.Text     = dttable_branch[0].city;
                txt_state.Text    = dttable_branch[0].state;
                txt_postcode.Text = dttable_branch[0].postcode;
                txt_country.Text  = dttable_branch[0].country_name;
                link_lbl_url.Text = dttable_branch[0].url;
                txt_branch.Text   = dttable_branch[0].branch_name;

                grd_contact.DataSource = null;
                grd_contact.DataSource = Organisation_contact_ds.Select_organisation_contact(dttable_branch[0].organisation);
            }
        }
示例#3
0
        private void Update_contact()
        {
            DataTable dttable_contact = (DataTable)grd_contact.DataSource;

            using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.VehicleDealershipConnectionString))
            {
                conn.Open();

                using (SqlBulkCopy bulkCopy = new SqlBulkCopy(conn))
                {
                    bulkCopy.DestinationTableName = "[misc].[bulkcopy_table]";

                    Bulkcopy_table_ds.Delete_by_user();
                    try
                    {
                        DataColumn dt_col1 = new DataColumn("modified_by", typeof(int));
                        dt_col1.DefaultValue = Program.System_user.UserID;
                        dttable_contact.Columns.Add(dt_col1);

                        bulkCopy.ColumnMappings.Add("contact", "nvarchar1");
                        bulkCopy.ColumnMappings.Add("remark", "nvarchar2");
                        bulkCopy.ColumnMappings.Add("modified_by", "created_by");
                        bulkCopy.WriteToServer(dttable_contact);

                        Organisation_contact_ds.Update_insert_organisation_contact(OrganisationID);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("An error has occurred. Contact cannot be updated. \n\n Message: " +
                                        ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                conn.Close();
            }
        }
示例#4
0
        private void Form_organisation_Shown(object sender, EventArgs e)
        {
            if (!Program.System_user.Has_permission(Class_enum.User_permission.VIEW_ORGANISATION) &&
                !Program.System_user.Has_permission(Class_enum.User_permission.ADD_EDIT_ORGANISATION))
            {
                MessageBox.Show("You do not have sufficient permission to perform this action!",
                                "ACCESS DENIED", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }

            // ##################### GRD_CONTACT #####################
            grd_contact.DataSource = Organisation_contact_ds.Select_organisation_contact(OrganisationID);
            grd_contact.AutoResizeColumns();
            // database column nvarchar length is 100
            Class_datagridview.Set_max_length_grd_col_same_with_datatable_col(grd_contact, "contact", "remark");
            // allow dbnull because empty string will enter dbnull to datagridviewcolumn
            ((DataTable)grd_contact.DataSource).Columns["remark"].AllowDBNull = true;
            // ##################### END GRD_CONTACT #####################

            Country_ds.sp_select_countryDataTable dttable_country = Country_ds.Select_country();

            // ##################### GRD_BRANCH #####################
            Organisation_branch_ds.sp_select_organisation_branch_by_orgDataTable dttable_branch = Organisation_branch_ds.Select_organisation_branch_by_org(OrganisationID);

            dttable_branch.Columns["address"].AllowDBNull  = true;
            dttable_branch.Columns["city"].AllowDBNull     = true;
            dttable_branch.Columns["state"].AllowDBNull    = true;
            dttable_branch.Columns["postcode"].AllowDBNull = true;
            dttable_branch.Columns.Remove("modified_by");            // no need show this

            grd_branch.DataSource = dttable_branch;
            grd_branch.Columns["organisation_branch"].Visible = false;
            grd_branch.RowsDefaultCellStyle.WrapMode          = DataGridViewTriState.True;
            grd_branch.AutoResizeColumns();
            grd_branch.AutoResizeRows();

            Class_datagridview.Set_max_length_grd_col_same_with_datatable_col(grd_branch, "branch_name", "address", "city", "state", "postcode");
            Class_datagridview.Replace_column_with_combobox_column(grd_branch, "country", dttable_country.Copy(), "country_name", "country");
            grd_branch.Columns["address"].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            // ##################### END GRD_BRANCH #####################

            Class_combobox.Setup_combobox(cmb_type, Organisation_type_ds.Select_organisation_type(),
                                          "organisation_type_description", "organisation_type");
            cmb_type.SelectedValue = 1;             // set default value to CORPORATE
            Class_combobox.Setup_combobox(cmb_country, dttable_country.Copy(), "country_name", "country");
            cmb_country.SelectedValue = 133;        // set default to malaysia

            if (OrganisationID == 0)
            {
                return;                                  // zero means adding new org
            }
            Organisation_ds.sp_select_organisationDataTable dttable_org = Organisation_ds.Select_organisation(OrganisationID);
            if (dttable_org.Rows.Count == 0)
            {
                return;
            }

            txt_name.Text             = dttable_org[0].name;
            txt_registration_no.Text  = dttable_org[0].registration_no;
            cmb_country.SelectedValue = dttable_org[0].country;
            cmb_type.SelectedValue    = dttable_org[0].organisation_type;
            txt_url.Text = dttable_org[0].url;
        }