protected void ui_BtnDelete_Click(object sender, EventArgs e)
 {
     ImageButton btn = (ImageButton)sender;
     Companies objData = new Companies();
     objData.LoadByPrimaryKey(Int32.Parse(btn.CommandArgument));
     objData.MarkAsDeleted();
     objData.Save();
     BindAllCompanies();
 }
        protected void ui_BtnEdit_Click(object sender, EventArgs e)
        {
            ImageButton btn = (ImageButton)sender;

            Companies objData = new Companies();
            objData.LoadByPrimaryKey(Int32.Parse(btn.CommandArgument));
            ui_txtCompNameEn.Text = objData.CompNameEng;
            ui_txtCompNameAr.Text = objData.CompNameAr;
            ui_txtCompCode.Text = objData.Comp_Code;
            ui_txtOldEmail.Text = objData.OLD_EMAIL;
            ui_txtName1.Text = objData.Doctor_Name;
            ui_txtNewEmail1.Text = objData.New_Email;
            ui_txtNumber1.Text = objData.Phone_Number;
            ui_txtName2.Text = objData.Doctor_Name_2;
            ui_txtNewEmail2.Text = objData.New_Email_2;
            ui_txtNumber2.Text = objData.Phone_Number2;

            ui_btnSave.Text = "Save";
            SavedCompaniesObj = objData;
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Companies obj = new Companies();

            obj.Where.Login_Code.Value = input_username.Text;
            obj.Where.Login_Code.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;

            obj.Where.Login_Code.Conjuction = MyGeneration.dOOdads.WhereParameter.Conj.And;

            obj.Where.Login_Password.Value = input_password.Text;
            obj.Where.Login_Password.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;

            if (obj.Query.Load())
            {
                CodeGlobal.LogedInCompany = obj;
                Response.Redirect("Home.aspx");
            }
            else
            {
                CodeGlobal.LogedInCompany = null;
                lblResult.Text = "Your Code or Password error please try again !";
            }
        }
        private void BindCompanies()
        {
            ListItem item = new ListItem(" --- Select All ----", "-1");

            // Bind Companies
            Companies objCompany = new Companies();
            objCompany.LoadAll();
            ui_drpCompanies.DataSource = objCompany.DefaultView;
            ui_drpCompanies.DataTextField = Companies.ColumnNames.CompNameEng;
            ui_drpCompanies.DataValueField = Companies.ColumnNames.CompanyID;
            ui_drpCompanies.DataBind();
            ui_drpCompanies.Items.Insert(0, item);

            ui_ddl_SearchCompany.DataSource = objCompany.DefaultView;
            ui_ddl_SearchCompany.DataTextField = Companies.ColumnNames.CompNameEng;
            ui_ddl_SearchCompany.DataValueField = Companies.ColumnNames.CompanyID;
            ui_ddl_SearchCompany.DataBind();
            ui_ddl_SearchCompany.Items.Insert(0, item);
        }
 protected void ui_BtnSearch_Click(object sender, EventArgs e)
 {
     Companies objData = new Companies();
     objData.SearchByName(ui_TxtSearch.Text);
     ui_GvData.DataSource = objData.DefaultView;
     ui_GvData.DataBind();
 }
        /// <summary>
        /// Save Company Info
        /// </summary>
        private void SaveCompanyInfo()
        {
            try
            {
                if (SavedCompaniesObj != null)
                {
                    SavedCompaniesObj.CompNameEng = ui_txtCompNameEn.Text;
                    SavedCompaniesObj.CompNameAr = ui_txtCompNameAr.Text;
                    SavedCompaniesObj.Comp_Code = ui_txtCompCode.Text;
                    SavedCompaniesObj.OLD_EMAIL = ui_txtOldEmail.Text;
                    SavedCompaniesObj.Doctor_Name = ui_txtName1.Text;
                    SavedCompaniesObj.New_Email = ui_txtNewEmail1.Text;
                    SavedCompaniesObj.Phone_Number = ui_txtNumber1.Text;
                    SavedCompaniesObj.Doctor_Name_2 = ui_txtName2.Text;
                    SavedCompaniesObj.New_Email_2 = ui_txtNewEmail2.Text;
                    SavedCompaniesObj.Phone_Number2 = ui_txtNumber2.Text;
                    SavedCompaniesObj.Checked = true;
                }

                SavedCompaniesObj.Save();
                SavedCompaniesObj = null;

                ui_lb_msg.ForeColor = System.Drawing.Color.Green;
                ui_lb_msg.Text = "The record saved successfully";
            }
            catch
            {
                ui_lb_msg.ForeColor = System.Drawing.Color.Red;
                ui_lb_msg.Text = "Problem while saving the record";
            }
        }
 private void BindAllCompanies()
 {
     Companies objData = new Companies();
     objData.LoadAll();
     ui_GvData.DataSource = objData.DefaultView;
     ui_GvData.DataBind();
 }
        /// <summary>
        /// Add Company Info
        /// </summary>
        private void AddCompanyInfo()
        {
            try
            {
                Companies objData = new Companies();

                objData.AddNew();

                objData.CompNameEng = ui_txtCompNameEn.Text;
                objData.CompNameAr = ui_txtCompNameAr.Text;
                objData.Comp_Code = ui_txtCompCode.Text;
                objData.OLD_EMAIL = ui_txtOldEmail.Text;
                objData.Doctor_Name = ui_txtName1.Text;
                objData.New_Email = ui_txtNewEmail1.Text;
                objData.Phone_Number = ui_txtNumber1.Text;
                objData.Doctor_Name_2 = ui_txtName2.Text;
                objData.New_Email_2 = ui_txtNewEmail2.Text;
                objData.Phone_Number2 = ui_txtNumber2.Text;
                objData.Checked = true;

                objData.Save();

                ui_lb_msg.ForeColor = System.Drawing.Color.Green;
                ui_lb_msg.Text = "The new record saved successfully";

                ResetFields();
            }
            catch
            {
                ui_lb_msg.ForeColor = System.Drawing.Color.Red;
                ui_lb_msg.Text = "Problem while saving the new record";
            }
        }
 protected void ui_btn_Click_Click(object sender, EventArgs e)
 {
     ResetFields();
     ui_btnSave.Text = "Add";
     SavedCompaniesObj = null;
 }
        /// <summary>
        /// Load data for all drop down lists.
        /// </summary>
        private void BindDropDownListsData()
        {
            ListItem item = new ListItem(" --- Select ----", "-1");

            // Bind Companies
            Companies objCompany = new Companies();
            objCompany.LoadAll();
            ui_drpCompanies.DataSource = objCompany.DefaultView;
            ui_drpCompanies.DataTextField = Companies.ColumnNames.CompNameEng;
            ui_drpCompanies.DataValueField = Companies.ColumnNames.CompanyID;
            ui_drpCompanies.DataBind();
            ui_drpCompanies.Items.Insert(0, item);

            // Bind Manufactures.
            ui_drpManufactures.DataSource = objCompany.DefaultView;
            ui_drpManufactures.DataTextField = Companies.ColumnNames.CompNameEng;
            ui_drpManufactures.DataValueField = Companies.ColumnNames.CompanyID;
            ui_drpManufactures.DataBind();
            ui_drpManufactures.Items.Insert(0, item);

            // Bind Dosage Forms
            Dosage_form objDosageForm = new Dosage_form();
            objDosageForm.LoadAll();
            ui_drpDosageForm.DataSource = objDosageForm.DefaultView;
            ui_drpDosageForm.DataTextField = Dosage_form.ColumnNames.Dosage_form;
            ui_drpDosageForm.DataValueField = Dosage_form.ColumnNames.DosageFormID;
            ui_drpDosageForm.DataBind();
            ui_drpDosageForm.Items.Insert(0, item);

            // Bind Registeration_Committee_Type
            Registeration_Committee_Type objCommitteType = new Registeration_Committee_Type();
            objCommitteType.LoadAll();
            ui_drpCommitteType.DataSource = objCommitteType.DefaultView;
            ui_drpCommitteType.DataTextField = Registeration_Committee_Type.ColumnNames.CommitteType;
            ui_drpCommitteType.DataValueField = Registeration_Committee_Type.ColumnNames.ID;
            ui_drpCommitteType.DataBind();
            ui_drpCommitteType.Items.Insert(0, item);

            // Bind File Types
            FileType objFileTypes = new FileType();
            objFileTypes.LoadAll();
            ui_drpFileType.DataSource = objFileTypes.DefaultView;
            ui_drpFileType.DataTextField = FileType.ColumnNames.FileType;
            ui_drpFileType.DataValueField = FileType.ColumnNames.FileTypeID;

            ui_drpFileType.DataBind();
            //ui_drpFileType.Items.Insert(0, item);
        }
        /// <summary>
        /// Load data for all drop down lists.
        /// </summary>
        private void BindDropDownListsData()
        {
            ListItem item = new ListItem(" --- Select ----", "-1");

            // Bind Companies
            Companies objCompany = new Companies();
            objCompany.LoadAll();
            ui_drpCompanies.DataSource = objCompany.DefaultView;
            ui_drpCompanies.DataTextField = Companies.ColumnNames.CompNameEng;
            ui_drpCompanies.DataValueField = Companies.ColumnNames.CompanyID;
            ui_drpCompanies.DataBind();
            ui_drpCompanies.Items.Insert(0, item);

            // Bind Manufactures.
            ui_drpManufactures.DataSource = objCompany.DefaultView;
            ui_drpManufactures.DataTextField = Companies.ColumnNames.CompNameEng;
            ui_drpManufactures.DataValueField = Companies.ColumnNames.CompanyID;
            ui_drpManufactures.DataBind();
            ui_drpManufactures.Items.Insert(0, item);

            // Bind Dosage Forms
            Dosage_form objDosageForm = new Dosage_form();
            objDosageForm.LoadAll();
            ui_drpDosageForm.DataSource = objDosageForm.DefaultView;
            ui_drpDosageForm.DataTextField = Dosage_form.ColumnNames.Dosage_form;
            ui_drpDosageForm.DataValueField = Dosage_form.ColumnNames.DosageFormID;
            ui_drpDosageForm.DataBind();
            ui_drpDosageForm.Items.Insert(0, item);

            // Bind Registeration_Committee_Type
            Registeration_Committee_Type objCommitteType = new Registeration_Committee_Type();
            objCommitteType.LoadAll();
            ui_drpCommitteType.DataSource = objCommitteType.DefaultView;
            ui_drpCommitteType.DataTextField = Registeration_Committee_Type.ColumnNames.CommitteType;
            ui_drpCommitteType.DataValueField = Registeration_Committee_Type.ColumnNames.ID;
            ui_drpCommitteType.DataBind();
            ui_drpCommitteType.Items.Insert(0, item);

            uiDropDownListCommitterType_Before.DataSource = objCommitteType.DefaultView;
            uiDropDownListCommitterType_Before.DataTextField = Registeration_Committee_Type.ColumnNames.CommitteType;
            uiDropDownListCommitterType_Before.DataValueField = Registeration_Committee_Type.ColumnNames.ID;
            uiDropDownListCommitterType_Before.DataBind();
            uiDropDownListCommitterType_Before.Items.Insert(0, item);

            //License Type
            TradePricingLicenseType licenseTypes = new TradePricingLicenseType();
            licenseTypes.LoadAll();
            uiDropDownListLicenseType.DataSource = licenseTypes.DefaultView;
            uiDropDownListLicenseType.DataTextField = TradePricingLicenseType.ColumnNames.Name;
            uiDropDownListLicenseType.DataValueField = TradePricingLicenseType.ColumnNames.TradePricingLicenseTypeID;
            uiDropDownListLicenseType.DataBind();
            uiDropDownListLicenseType.Items.Insert(0, item);

            //status Type
            TradePricingStatus statusTypes = new TradePricingStatus();
            statusTypes.LoadAll();
            uiDropDownListStatusType.DataSource = statusTypes.DefaultView;
            uiDropDownListStatusType.DataTextField = TradePricingStatus.ColumnNames.Name;
            uiDropDownListStatusType.DataValueField = TradePricingStatus.ColumnNames.TradePricingStatusID;
            uiDropDownListStatusType.DataBind();
            uiDropDownListStatusType.Items.Insert(0, item);

            //sector Type
            SectorType sectorTypes = new SectorType();
            sectorTypes.LoadAll();
            uiDropDownListSectorType.DataSource = sectorTypes.DefaultView;
            uiDropDownListSectorType.DataTextField = SectorType.ColumnNames.Name;
            uiDropDownListSectorType.DataValueField = SectorType.ColumnNames.SectorTypeID;
            uiDropDownListSectorType.DataBind();
            uiDropDownListSectorType.Items.Insert(0, item);

            // Bind File Types
            FileType objFileTypes = new FileType();
            objFileTypes.LoadAll();
            ui_drpFileType.DataSource = objFileTypes.DefaultView;
            ui_drpFileType.DataTextField = FileType.ColumnNames.FileType;
            ui_drpFileType.DataValueField = FileType.ColumnNames.FileTypeID;

            ui_drpFileType.DataBind();
            //ui_drpFileType.Items.Insert(0, item);
        }