private void GetCompanyAddress() { string _companyNo = ConfigurationManager.GetConfiguration().CompanyNo; MAS_COMPANY cData = new MAS_COMPANY(); Mas_Company_Manage manage = new Mas_Company_Manage(); cData = manage.GetMasCompanyByID(_companyNo); txtContactAdd.Text = cData.CompanyAddressTH; }
private void InitialDDLDepartment() { string _CompanyCode = "2000"; //Default Company Code 2000 [GED] List <MAS_DEPARTMENT> lData = new List <MAS_DEPARTMENT>(); Mas_Company_Manage manage = new Mas_Company_Manage(); lData = manage.ListDepartmentByComCode(_CompanyCode); ddlDepartment.DataSource = lData; ddlDepartment.DataBind(); ddlDepartment.Items.Insert(0, new ListItem("== เลือกแผนก ==", "0")); }
protected void gvListItem_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { int totalCell = e.Row.Cells.Count; for (int i = 0; i < e.Row.Cells.Count; i++) { string cellName = ""; TemplateField fieldFooter = (TemplateField)((DataControlFieldCell)e.Row.Cells[i]).ContainingField; cellName = fieldFooter.HeaderText; if (cellName.Equals("บริษัท")) { DropDownList ddlCompany = new DropDownList(); ddlCompany.ID = "ddlCompany"; ddlCompany.Font.Size = 10; ddlCompany.DataTextField = "CompanyNameTH"; ddlCompany.DataValueField = "CompanyNo"; Mas_Company_Manage manage = new Mas_Company_Manage(); List <MAS_COMPANY> lRet = new List <MAS_COMPANY>(); lRet = manage.ListMasCompany(); ddlCompany.DataSource = lRet; ddlCompany.DataBind(); //ddlCompany.Style.Add("Font-Size", "11px"); ddlCompany.CssClass = "lblGridDetail"; ddlCompany.Width = 250; e.Row.Cells[i].Controls.Add(ddlCompany); e.Row.Cells[i].Attributes.Add("align", "left"); } else if (cellName.Equals("รายละเอียด")) { TextBox txt = new TextBox(); txt.ID = "TxtDetail"; //txt.Style.Add("Font-Size", "11px"); //txt.Width = 150; txt.CssClass = "TxtGridDetail"; e.Row.Cells[i].Controls.Add(txt); e.Row.Cells[i].Attributes.Add("align", "left"); } else if (cellName.Equals("แก้ไข")) { LinkButton lbtnAdd = new LinkButton(); lbtnAdd.ID = "lbtnAdd"; lbtnAdd.CommandName = "AddNew"; lbtnAdd.Text = "เพิ่ม"; //lbtnAdd.Style.Add("Font-Size", "11px"); lbtnAdd.CssClass = "lblGridLink"; e.Row.Cells[i].Controls.Add(lbtnAdd); e.Row.Cells[i].Attributes.Add("align", "center"); } else { if (!cellName.Contains("บาท")) { TextBox txt = new TextBox(); txt.ID = "TxtColumn" + i.ToString(); //txt.Font.Size = 10; //txt.Width = 90; //txt.Style.Add("Font-Size", "11px"); txt.CssClass = "TxtGridDetail"; e.Row.Cells[i].Controls.Add(txt); e.Row.Cells[i].Attributes.Add("align", "center"); } } } } else if (e.Row.RowType == DataControlRowType.DataRow) { string cellName = string.Empty; TemplateField fieldDataRow = null; Label lbl = null; for (int i = 0; i < e.Row.Cells.Count; i++) { string _rowName = ""; fieldDataRow = (TemplateField)((DataControlFieldCell)e.Row.Cells[i]).ContainingField; cellName = fieldDataRow.HeaderText; if (cellName.Equals("บริษัท")) { lbl = new Label(); lbl.ID = "lblCompamy"; lbl.Text = (e.Row.DataItem as DataRowView).Row["ItemColumn1"].ToString(); //lbl.Style.Add("Font-Size", "11px"); lbl.CssClass = "lblGridDetail"; e.Row.Cells[i].Controls.Add(lbl); e.Row.Cells[i].Attributes.Add("align", "left"); } else if (cellName.Equals("รายละเอียด")) { lbl = new Label(); lbl.ID = "lblDetail"; lbl.Text = (e.Row.DataItem as DataRowView).Row["ItemColumn2"].ToString(); //lbl.Style.Add("Font-Size", "11px"); lbl.CssClass = "lblGridDetail"; e.Row.Cells[i].Controls.Add(lbl); e.Row.Cells[i].Attributes.Add("align", "left"); } else if (cellName.Equals("แก้ไข")) { LinkButton lbtnDelete = new LinkButton(); lbtnDelete.ID = "lbtnDelete"; lbtnDelete.CommandName = "Delete"; lbtnDelete.Text = string.IsNullOrWhiteSpace((e.Row.DataItem as DataRowView).Row["ItemColumn1"].ToString()) ? "" : "ลบ"; //lbtnDelete.Style.Add("Font-Size", "11px"); lbtnDelete.CssClass = "lblGridLink"; e.Row.Cells[i].Controls.Add(lbtnDelete); e.Row.Cells[i].Attributes.Add("align", "center"); } else { _rowName = "ItemColumn" + (i + 1).ToString(); lbl = new Label(); lbl.ID = "lblItemColumn" + i.ToString(); lbl.Text = (e.Row.DataItem as DataRowView).Row[_rowName].ToString(); //lbl.Style.Add("Font-Size", "11px"); lbl.CssClass = "lblGridDetail"; e.Row.Cells[i].Controls.Add(lbl); e.Row.Cells[i].Attributes.Add("align", "center"); } } } }