Exemplo n.º 1
0
 protected void uiButtonSearch_Click(object sender, EventArgs e)
 {
     BLL.AirPorts objData = new AirPorts();
     objData.SearchAirPorts(uiTextBoxSearch.Text);
     uiGridViewAirPorts.DataSource = objData.DefaultView;
     uiGridViewAirPorts.DataBind();
 }
Exemplo n.º 2
0
        protected void uiGridViewAirLines_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView objData = (DataRowView)e.Row.DataItem;
                AirPorts From = new AirPorts();
                AirPorts To = new AirPorts();
                Companies Comp = new Companies();
                From.LoadByPrimaryKey(Convert.ToInt32(objData["FromAirPortID"].ToString()));
                Label temp = (Label)e.Row.FindControl("uiLabelFromName");
                temp.Text = From.EnName;

                To.LoadByPrimaryKey(Convert.ToInt32(objData["ToAirPortID"].ToString()));
                Label temp2 = (Label)e.Row.FindControl("uiLabelToName");
                temp2.Text = To.EnName;

                Comp.LoadByPrimaryKey(Convert.ToInt32(objData["CompanyID"].ToString()));
                Label temp3 = (Label)e.Row.FindControl("uiLabelCompanyName");
                temp3.Text = Comp.ArName;
            }
        }
Exemplo n.º 3
0
        protected void uiLinkButtonUpload_Click(object sender, EventArgs e)
        {
            if (uiFileUploadAirLines.HasFile)
            {
                ArrayList nonUploaded = new ArrayList();
                uiFileUploadAirLines.SaveAs(Server.MapPath("~/FileUploads/" + uiFileUploadAirLines.FileName));
                string connectionString = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0;HDR=NO;""", Server.MapPath("~/FileUploads/" + uiFileUploadAirLines.FileName));

                string strSQL = "SELECT * FROM [sheet1$]";
                OleDbConnection excelConnection = new OleDbConnection(connectionString);
                excelConnection.Open();
                OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);

                DataTable dTable = new DataTable();

                dataAdapter.Fill(dTable);
                AirLines objData = new AirLines();
                if (uiDropDownListUploadType.SelectedValue == "1")
                {

                    foreach (DataRow item in dTable.Rows)
                    {
                        AirPorts Fcity = new AirPorts();
                        Fcity.GetAirPortByCode(item[0].ToString());

                        AirPorts Tcity = new AirPorts();
                        Tcity.GetAirPortByCode(item[1].ToString());

                        if (Fcity.RowCount == 0 || Tcity.RowCount == 0)
                        {
                            nonUploaded.Add("From : " + item[0].ToString() + " - To : " + item[1].ToString());
                            continue;
                        }
                        else
                        {
                            objData.AddNew();
                            objData.CompanyID = Convert.ToInt32(uiDropDownListCompanyUpload.SelectedValue);
                            objData.FromAirPortID = Fcity.AirPortID;
                            objData.ToAirPortID = Tcity.AirPortID;
                        }
                    }
                }
                else if (uiDropDownListUploadType.SelectedValue == "2")
                {

                    foreach (DataRow item in dTable.Rows)
                    {

                        AirPorts Fcity = new AirPorts();
                        Fcity.GetAirPortByName(item[0].ToString());

                        AirPorts Tcity = new AirPorts();
                        Tcity.GetAirPortByName(item[1].ToString());

                        if (Fcity.RowCount == 0 || Tcity.RowCount == 0)
                        {
                            nonUploaded.Add("From : " + item[0].ToString() + " - To : " + item[1].ToString());
                            continue;
                        }
                        else
                        {
                            objData.AddNew();
                            objData.CompanyID = Convert.ToInt32(uiDropDownListCompanyUpload.SelectedValue);
                            objData.FromAirPortID = Fcity.AirPortID;
                            objData.ToAirPortID = Tcity.AirPortID;
                        }
                    }
                }

                objData.Save();
                BindData();

                uiGridViewLog.DataSource = nonUploaded;
                //uiGridViewLog.Columns[1].HeaderText = "These items faild to insert";
                uiGridViewLog.DataBind();
            }
        }
Exemplo n.º 4
0
        private void LoadDDLs()
        {
            Companies comp = new Companies();
            comp.SearchCompanies("", 0, 1, 1);
            uiDropDownListCompanies.DataSource = comp.DefaultView;
            uiDropDownListCompanies.DataTextField = "ArName";
            uiDropDownListCompanies.DataValueField = "CompanyID";
            uiDropDownListCompanies.DataBind();

            Companies comp1 = new Companies();
            comp1.SearchCompanies("", 0, 1, 1);
            uiDropDownListCompanyUpload.DataSource = comp1.DefaultView;
            uiDropDownListCompanyUpload.DataTextField = "ArName";
            uiDropDownListCompanyUpload.DataValueField = "CompanyID";
            uiDropDownListCompanyUpload.DataBind();

            AirPorts city = new AirPorts();
            city.LoadAll();
            uiDropDownListFromCity.DataSource = city.DefaultView;
            uiDropDownListToCity.DataSource = city.DefaultView;

            uiDropDownListFromCity.DataTextField = "EnName";
            uiDropDownListToCity.DataTextField = "EnName";

            uiDropDownListFromCity.DataValueField = "AirPortID";
            uiDropDownListToCity.DataValueField = "AirPortID";

            uiDropDownListFromCity.DataBind();
            uiDropDownListToCity.DataBind();
        }
Exemplo n.º 5
0
        protected void uiGridViewAirPorts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditAirPort")
            {
                AirPorts objData = new AirPorts();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                uiTextBoxEnName.Text = objData.EnName;
                uiTextBoxArName.Text = objData.ArName;
                uiTextBoxCode.Text = objData.AirPortCode;

                uiPanelViewAirPorts.Visible = false;
                uiPanelEdit.Visible = true;
                CurrentAirPort = objData;
            }
            else if (e.CommandName == "DeleteAirPort")
            {
                AirPorts objData = new AirPorts();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                objData.MarkAsDeleted();
                objData.Save();
                CurrentAirPort = null;
                BindData();
            }
        }
Exemplo n.º 6
0
 private void BindData()
 {
     BLL.AirPorts objData = new AirPorts();
     objData.LoadAll();
     uiGridViewAirPorts.DataSource = objData.DefaultView;
     uiGridViewAirPorts.DataBind();
 }
Exemplo n.º 7
0
        private void AddNewRecord()
        {
            AirPorts objData = new AirPorts();
            objData.AddNew();
            objData.EnName = uiTextBoxEnName.Text;
            objData.ArName = uiTextBoxArName.Text;
            objData.AirPortCode = uiTextBoxCode.Text;

            objData.Save();
        }