protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Panel2.Visible = true; Panel3.Visible = true; Panel4.Visible = false; Label3.Text = GridView1.SelectedValue.ToString(); string s; s = "select * from request where reqno='" + Label3.Text + "'"; SqlDataSource2.SelectCommand = s; SqlDataSource2.DataBind(); dr = a1.disp(s); string ClientID = ""; if (dr.Read()) { ClientID = dr.GetValue(3).ToString(); } while (dr.Read()) { s = "select * from clientreg reg where ClientID ='" + ClientID + "' "; SqlDataSource3.SelectCommand = s; SqlDataSource3.DataBind(); GridView1.Enabled = false; } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowIndex == GridView1.SelectedIndex) { //row.RowIndex gives the current row nr SqlDataSource3.DeleteCommand = "DELETE FROM [TIMESLOTS] WHERE Timeslot =" + "\"" + GridView1.Rows[row.RowIndex].Cells[2].Text + "\" AND " + "Patient = " + "\"" + GridView1.Rows[row.RowIndex].Cells[3].Text + "\" AND " + "DoctorName=" + "\"" + GridView1.Rows[row.RowIndex].Cells[5].Text + "\" AND " + "AppointmentDate=" + "\"" + GridView1.Rows[row.RowIndex].Cells[6].Text + "\";"; SqlDataSource3.DataBind(); SqlDataSource3.Delete(); GridView1.DataBind(); if (GridView1.Rows.Count == 0) { Label4.Text = "You currently do not have any appointments."; } else { Label4.Text = "The appointment was successfully canceled!"; } } } }
//创建EDITFORM前 protected void ASPxGridView1_HtmlEditFormCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditFormEventArgs e) { string Sql3 = "SELECT PT_PART,PT_DESC2 FROM COPY_PT_MSTR where pt_phantom=0 order by PT_PART "; SqlDataSource3.SelectCommand = Sql3; SqlDataSource3.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { SqlDataSource3.SelectCommand = "SELECT * FROM [TIMESLOTS] WHERE [PATIENT]=\"" + user + "\""; SqlDataSource3.DataBind(); GridView1.DataBind(); if (Calendar1.SelectedDate < DateTime.Now) { Button1.Enabled = false; Label4.Text = "Please choose a valid date!"; } else { Label4.Text = "The appointment you want to book is: \"" + Calendar1.SelectedDate.ToShortDateString() + " at " + DropDownList2.Text + "\"<br/>The appointment will be together with " + DropDownList1.Text; Button1.Enabled = true; if (System.Web.HttpContext.Current.User.IsInRole("admin") || System.Web.HttpContext.Current.User.IsInRole("secretary")) { SqlDataSource3.SelectCommand = "SELECT * FROM [TIMESLOTS] WHERE NOT [APPOINTMENTDATE] IS NULL;"; SqlDataSource3.DataBind(); GridView1.DataBind(); } else { SqlDataSource3.SelectCommand = "SELECT * FROM [TIMESLOTS] WHERE PATIENT=\"" + user + "\""; SqlDataSource3.DataBind(); GridView1.DataBind(); } // Needed for the Drop Down List Times SqlDataSource2.SelectCommand = "SELECT [Timeslot] FROM [Timeslots] WHERE (([DoctorName] = ?) AND ([Patient] IS NULL) AND ([AppointmentDate] IS NULL))"; SqlDataSource2.DataBind(); DropDownList2.DataBind(); GridView1.DataBind(); } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Panel2.Visible = true; Panel3.Visible = true; Panel4.Visible = false; Label2.Text = GridView1.SelectedValue.ToString(); string s; s = "select * from request where reqno='" + Label2.Text + "'"; SqlDataSource2.SelectCommand = s; SqlDataSource2.DataBind(); dr = a1.disp(s); string clientid = ""; if (dr.Read()) { clientid = dr.GetValue(3).ToString(); } // while (dr.Read()) // { s = "select * from clientreg where clientid ='" + clientid + "' "; SqlDataSource3.SelectCommand = s; SqlDataSource3.DataBind(); s = "select * from request where reqno=" + Label2.Text + " "; dr = a1.disp(s); string pname = "", qty = "0"; if (dr.Read()) { pname = dr.GetValue(1).ToString(); qty = dr.GetValue(2).ToString(); } Label12.Text = pname; s = "Select * from pstock where pname='" + pname + "' "; string cstock = "0"; dr = a1.disp(s); if (dr.Read()) { cstock = dr.GetValue(1).ToString(); } Label5.Text = cstock; Label7.Text = qty; if (int.Parse(qty) > int.Parse(cstock)) { Button1.Enabled = false; } else { Button1.Enabled = true; } //} }
public void UpdateTeacher() { SqlDataSource3.DataBind(); TeacherDropDown.DataBind(); SqlDataSource1.DataBind(); GridView1.DataBind(); }
public void show_Member(string MEM_CODE) { string sql = "select * from VMember where COLLEGE_ID =" + cid + " and member_code = '" + MEM_CODE + "' "; DataTable dt = new DataTable(); MyClass cs = new MyClass(); dt = cs.GetTable(sql); if (dt.Rows.Count > 0) { TextBox1.Text = dt.Rows[0]["Member_Name"].ToString(); TextBox2.Text = dt.Rows[0]["Dep_name"].ToString(); TextBox3.Text = dt.Rows[0]["College_Name"].ToString(); lblMem_Id.Text = dt.Rows[0]["Mem_ID"].ToString(); lblRole.Text = dt.Rows[0]["Role"].ToString(); Image1.ImageUrl = "~/img/" + dt.Rows[0]["photo"].ToString(); SqlDataSource3.SelectCommand = "SELECT Bir_id, Acc_code, Title, Author, Book_type, Issue_dt,due_dt, Photo FROM VBook_Issue_Return WHERE (Is_return = 0) AND (Mem_id = " + lblMem_Id.Text + ")"; SqlDataSource3.DataBind(); } else { TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; Image1.ImageUrl = "~/img/000.jpg"; } }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theUserId = theUserManager.getUserId(); theUserName = theUserManager.getUserName(); theProgramCode = "atpu1C00"; string Sql3 = "SELECT distinct a.PT_PART FROM COPY_PT_MSTR a left join copy_ptp_det b on a.PT_PART=b.PTP_PART " + "where b.ptp_phantom=0 and upper(a.pt_group)='M' and upper(b.ptp_site) in('DCEC-B','DCEC-C') order by PT_PART "; SqlDataSource3.SelectCommand = Sql3; SqlDataSource3.DataBind(); string Sql32 = "SELECT ABOM_COMP FROM ATPUBOMKZB order by ABOM_COMP "; SqlDataSource32.SelectCommand = Sql32; SqlDataSource32.DataBind(); string Sql33 = "SELECT ABOM_COMP FROM ATPUBOMKZB order by ABOM_COMP "; SqlDataSource33.SelectCommand = Sql32; SqlDataSource33.DataBind(); setCondition1(); setCondition2(); setCondition3(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string s; s = "select * from productreg where pname='" + DropDownList1.Text + "'"; SqlDataSource3.SelectCommand = s; SqlDataSource3.DataBind(); }
protected void txtSearch_Click(object sender, EventArgs e) { String search = txtSearchArtwork.Text; SqlDataSource3.SelectCommand = "Select * from Artwork where artworkName like '%" + search + "%'"; SqlDataSource3.DataBind(); Repeater1.DataBind(); }
protected void UploadDocument2(object sender, EventArgs e) { string input = "", DirRoot = "", filename = ""; int stringindex = 0, cut = 0; Boolean check = false; if (fuDocument2.HasFile) { HttpPostedFile postedFile = fuDocument2.PostedFile; DirRoot = System.IO.Path.GetExtension(postedFile.FileName).ToUpper().Replace(".", ""); SqlDataSource3.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; SqlDataSource3.SelectCommand = "select id,name from filename_extension"; SqlDataSource3.DataBind(); DataView ou1 = (DataView)SqlDataSource3.Select(DataSourceSelectArguments.Empty); for (int i = 0; i < ou1.Count; i++) { if (DirRoot.ToUpper() == ou1.Table.Rows[i]["name"].ToString().ToUpper()) { check = true; } } if (check) { int fileSize = fuDocument2.PostedFile.ContentLength; // Allow only files less than (16 MB)=16777216 bytes to be uploaded. if (fileSize < 16777216) { SqlDataSource sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; filename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + @"." + DirRoot; //AmazonUpload aws = new AmazonUpload(); //string imgurl = aws.AmazonUpload_file("", "upload/test", filename, postedFile.InputStream); Google.Apis.Auth.OAuth2.GoogleCredential credential = GCP_AUTH.AuthExplicit(); string imgurl = GCP_AUTH.upload_file_stream("", "upload/test", filename, postedFile.InputStream, credential); //fuDocument.SaveAs(Server.MapPath("important_images") + "\\" + filename); type2_Image.ImageUrl = imgurl; Image10.Visible = true; Image11.Visible = false; //GridView1.DataBind(); } else { ScriptManager.RegisterStartupScript(fuDocument2, fuDocument2.GetType(), "alert", "alert('File is out of memory 16MB!')", true); } } else { ScriptManager.RegisterStartupScript(fuDocument2, fuDocument2.GetType(), "alert", "alert('filename extension is not in role!')", true); } } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string command = SqlDataSource3.SelectCommand; // added just for debug purpose if (DropDownList1.SelectedValue == "all") { command = "SELECT land_id,region_name,land_name,area FROM tb_LAND,tb_REGION WHERE tb_LAND.region_id = tb_REGION.region_id"; } else { command = "SELECT land_id,region_name,land_name,area FROM tb_LAND,tb_REGION WHERE tb_LAND.region_id = tb_REGION.region_id AND tb_LAND.region_id='" + DropDownList1.SelectedItem.Value + "'"; } SqlDataSource3.SelectCommand = command; SqlDataSource3.DataBind(); }
protected void Button1_Click1(object sender, EventArgs e) { if (TextBox10.Text == "") { TextBox10.Text = "0"; } int MyNo = Int32.Parse(TextBox10.Text); if (Gridview1.Rows.Count >= MyNo) { Button1.Visible = false; lblMax.Text = "Maximum Book Is Issuesed"; return; } A_Handler = new Book_Issue_ReturnHandler(); A1 = new Book_Issue_Return(); // A1.Bir_id = Convert.ToInt32(DropDownList1.SelectedValue.ToString()); A1.Reg_id = Int32.Parse(lblReg_ID.Text); A1.Mem_id = Convert.ToInt32(lblMem_Id.Text); A1.Acc_id = Convert.ToInt32(lblAcc_ID.Text); A1.Issue_dt = Convert.ToDateTime(TextBox7.Text); A1.Issue_days = Convert.ToInt32(TextBox8.Text); A1.Due_dt = A1.Issue_dt.AddDays(A1.Issue_days); A1.Return_dt = A1.Issue_dt; A1.Due_day = 0; A1.Is_return = false; A1.Is_fine = false; A1.Fine_amt = 0; bool b = A_Handler.AddNewBook_Issue_Return(A1); if (b == true) { lblMax.Text = "Book is Issued"; //GridView1.DataBind(); } SqlDataSource3.SelectCommand = "SELECT Bir_id, Acc_code, Title, Author, Book_type, Issue_dt,due_dt, Photo FROM VBook_Issue_Return WHERE (Is_return = 0) AND (Mem_id = " + lblMem_Id.Text + ")"; SqlDataSource3.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetMasterValues(); string dateS = Request.QueryString["Date"]; DateTime t0 = new DateTime(); string sess = Request.QueryString["Session"]; bool Is_AM = true; try { t0 = Convert.ToDateTime(Request.QueryString["Date"]); if (sess.Contains("PM")) { Is_AM = false; } ViewState["Session_is_AM"] = Is_AM; ViewState["EditDate"] = t0; } catch { //try to get from session state? Is_AM = (bool)ViewState["Session_is_AM"]; t0 = (DateTime)ViewState["EditDate"]; } DateTime t1 = new DateTime(); DateTime t2 = new DateTime(); t1 = (Is_AM) ? t0.AddHours(8) : t0.AddHours(13); t2 = (Is_AM) ? t0.AddHours(13) : t0.AddHours(18); Label_Date.Text = t0.ToLongDateString(); SetUp(t1, t2, Is_AM); ExamsUtility u = new ExamsUtility(); bool b = u.AreRoomsMissing(t1, t2); if (!b) { Label_message.Text = "All Rooms are Allocated.. you can run again if you wish"; } Encode en = new Encode(); SqlDataSource3.SelectCommand = GetQueryStringRoomSummary(t1, t2, !b); SqlDataSource3.ConnectionString = en.GetDbConnection(); SqlDataSource3.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { if (Request.QueryString["cat"] != null) { if (Request.QueryString["cat"].ToString().Equals("notnull")) { String artworkCategory = Request.QueryString["artworkCategory"].ToString(); SqlDataSource3.SelectCommand = "Select * from Artwork where artworkCategory='" + artworkCategory + "'"; } } else { SqlDataSource3.SelectCommand = "Select * from Artwork"; SqlDataSource3.DataBind(); Repeater1.DataBind(); } } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Panel2.Visible = true; Label3.Text = GridView1.SelectedValue.ToString(); string s; s = "select * from request where reqno='" + Label3.Text + "'"; SqlDataSource2.SelectCommand = s; SqlDataSource2.DataBind(); dr = a1.disp(s); string cmpid = ""; if (dr.Read()) { cmpid = dr.GetValue(3).ToString(); } while (dr.Read()) { s = "select * from companyreg where cmpID ='" + cmpid + "' "; SqlDataSource3.SelectCommand = s; SqlDataSource3.DataBind(); } }
protected void Button_Assign_Click(object sender, EventArgs e) { //now we are actually going to do it??? string ErrorS = "Success!"; bool Is_AM = (bool)ViewState["Session_is_AM"]; DateTime t0 = new DateTime(); t0 = (DateTime)ViewState["EditDate"]; DateTime t1 = new DateTime(); DateTime t2 = new DateTime(); t1 = (Is_AM) ? t0.AddHours(8) : t0.AddHours(13); t2 = (Is_AM) ? t0.AddHours(13) : t0.AddHours(18); DateTime time_last = new DateTime(); List <Guid> Rooms = new List <Guid>(); ListBox lb = ListBox_Rooms; foreach (ListItem l in lb.Items) { if (l.Selected) { Rooms.Add(new Guid(l.Value)); } } //if no rooms allocated flag error if (Rooms.Count == 0) { ErrorS = "...you haven't allocated Any rooms"; goto ErrorExit; } ExamsUtility eu = new ExamsUtility(); eu.ClearDeskAssignments(t1, t2); //ought to clear all room allocations first... //ought to do this by query int n = 0; ExamsUtility u = new ExamsUtility(); u.ClearRoomAssignments(t1, t2); ExamRoom er = new ExamRoom(); n = 0; List <int> Room_Capacity = new List <int>(); foreach (Guid d in Rooms) { er.Load(d); Room_Capacity.Add(er.m_capacity); n++; } int nmax = n - 1; ScheduledComponentList scl1 = new ScheduledComponentList(); scl1.LoadList_Date(t1, t2); //order by DateTime time_last = ((ScheduledComponent)scl1.m_List[0]).m_Date; string s = GetQueryStringDay(t0.Year, t0.Month, t0.Day); // gets from sc ordered by datetime,NUMBER List <Guid> Components = new List <Guid>(); List <int> number = new List <int>(); List <DateTime> Start_Time = new List <DateTime>(); Encode en = new Encode(); string db_connection = en.GetDbConnection(); using (SqlConnection cn = new SqlConnection(db_connection)) { cn.Open(); using (SqlCommand cm = new SqlCommand(s, cn)) { using (SqlDataReader dr = cm.ExecuteReader()) { while (dr.Read()) { Components.Add(dr.GetGuid(1)); number.Add(dr.GetInt32(4)); Start_Time.Add(dr.GetDateTime(3)); } dr.Close(); } } cn.Close(); } //first apply rules... hopefully these will fit ... if not flag error back to ui int CurrentRoomCapacity = 0; string s_rule = DropDownList_Rule1Source.SelectedItem.Text; Guid rule_roomId = new Guid(DropDownList_Rule1Room.SelectedValue); n = 0; foreach (Guid d in Rooms) { if (d == rule_roomId) { CurrentRoomCapacity = Room_Capacity[n]; break; } } if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity)) { goto ErrorExit; } Room_Capacity[n] = CurrentRoomCapacity; if ((s_rule != "None") && (CheckBox1.Checked)) { Rooms.Remove(rule_roomId); nmax--; } s_rule = DropDownList_Rule2Source.SelectedItem.Text; rule_roomId = new Guid(DropDownList_Rule2Room.SelectedValue); n = 0; foreach (Guid d in Rooms) { if (d == rule_roomId) { CurrentRoomCapacity = Room_Capacity[n]; break; } } if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity)) { goto ErrorExit; } if ((s_rule != "None") && (CheckBox2.Checked)) { Rooms.Remove(rule_roomId); nmax--; } Room_Capacity[n] = CurrentRoomCapacity; s_rule = DropDownList_Rule3Source.SelectedItem.Text; rule_roomId = new Guid(DropDownList_Rule3Room.SelectedValue); n = 0; foreach (Guid d in Rooms) { if (d == rule_roomId) { CurrentRoomCapacity = Room_Capacity[n]; break; } } if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity)) { goto ErrorExit; } if ((s_rule != "None") && (CheckBox3.Checked)) { Rooms.Remove(rule_roomId); nmax--; } Room_Capacity[n] = CurrentRoomCapacity; s_rule = DropDownList_Rule4Source.SelectedItem.Text; rule_roomId = new Guid(DropDownList_Rule4Room.SelectedValue); n = 0; foreach (Guid d in Rooms) { if (d == rule_roomId) { CurrentRoomCapacity = Room_Capacity[n]; break; } } if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity)) { goto ErrorExit; } if ((s_rule != "None") && (CheckBox4.Checked)) { Rooms.Remove(rule_roomId); nmax--; } Room_Capacity[n] = CurrentRoomCapacity; s_rule = DropDownList_Rule5Source.SelectedItem.Text; rule_roomId = new Guid(DropDownList_Rule5Room.SelectedValue); n = 0; foreach (Guid d in Rooms) { if (d == rule_roomId) { CurrentRoomCapacity = Room_Capacity[n]; break; } } if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity)) { goto ErrorExit; } if ((s_rule != "None") && (CheckBox5.Checked)) { Rooms.Remove(rule_roomId); nmax--; } Room_Capacity[n] = CurrentRoomCapacity; ScheduledComponentList scl2 = new ScheduledComponentList(); foreach (ScheduledComponent c in scl1.m_List) { if (c.m_RoomId == Guid.Empty) { scl2.m_List.Add(c); } } //now we apply the rest //idea is we find the sc with most students.... and put into biggest room first //first correct room capacity? n = 0; // well i think we have all the information.... //going to assign biggest exam to biggest room first int index = 0; foreach (Guid d in Components) { //so new component.... //if there is a complete gap before we start this component we can clear room allocations.... //find the first (earliest) scheduled component foreach (ScheduledComponent c in scl2.m_List) { if (c.m_ComponentId == d) { if (c.m_RoomId == Guid.Empty) { if (c.m_Date > time_last.AddMinutes(10)) { //so this one starts at least 10 minutes after all sofar have finished.... time_last = c.m_Date.AddMinutes(c.m_TimeAllowed); //so can reset rooms..... ie back to full capacity? Room_Capacity.Clear(); n = 0; foreach (Guid d1 in Rooms) { er.Load(d1); Room_Capacity.Add(er.m_capacity); n++; } nmax = n - 1; } } } } n = 0; while ((Room_Capacity[n] == 0) && (n <= nmax)) { n++; } if (n > nmax) { ErrorS = "Ran out of room capacity !!"; goto ErrorExit; } //going to check if next one will fit in any room we have available... if so use it! search smallest first? for (int i = nmax; i >= 0; i--) { if (Room_Capacity[i] >= number[index]) { n = i; break; } } foreach (ScheduledComponent c in scl2.m_List) { if (c.m_ComponentId == d) { if (c.m_RoomId == Guid.Empty) { if (c.m_Date.AddMinutes(c.m_TimeAllowed) > time_last) { time_last = c.m_Date.AddMinutes(c.m_TimeAllowed); } //really ought to check to see if he has any other componets in this session and assign the same room/... foreach (ScheduledComponent c1 in scl1.m_List) { if (c1.m_StudentId == c.m_StudentId) { c.m_RoomId = c1.m_RoomId; } } if (c.m_RoomId == Guid.Empty) { c.m_RoomId = Rooms[n]; Room_Capacity[n]--; } c.Save(); foreach (ScheduledComponent c1 in scl2.m_List) { if ((c1.m_StudentId == c.m_StudentId) && (c1.m_RoomId == Guid.Empty)) { c.m_RoomId = Rooms[n]; c.Save(); //Room_Capacity[n]--; should already have cleared clashes } } } } while ((Room_Capacity[n] == 0) && (n < nmax)) { n++; } if (n > nmax) { ErrorS = "Ran out of room capacity !!"; goto ErrorExit; } } index++; } //check?? //success; open the summary panel Panel_left1.Visible = false; Panel_right1.Visible = false; Label_message.Text = "Rooms Allocated Successfully."; Label_message.Visible = true; SqlDataSource3.SelectCommand = GetQueryStringRoomSummary(t1, t2, true); SqlDataSource3.ConnectionString = en.GetDbConnection(); SqlDataSource3.DataBind(); return; ErrorExit : Label_message.Text = ErrorS; Label_message.BackColor = System.Drawing.Color.Red; return; }
public void UpdateSection() { SqlDataSource3.DataBind(); DropDownList2.DataBind(); }
protected void serch_Click1(object sender, EventArgs e) { cdf.Open(); SqlCommand del1 = new SqlCommand("delete from help_rep_cus", cdf); del1.ExecuteScalar(); SqlCommand del2 = new SqlCommand("delete from help_repcus_tarikh", cdf); del2.ExecuteScalar(); SqlCommand del3 = new SqlCommand("delete from help_repcus2", cdf); del3.ExecuteScalar(); SqlCommand del4 = new SqlCommand("delete from help_repcus_now", cdf); del4.ExecuteScalar(); SqlCommand del5 = new SqlCommand("delete from help_3", cdf); del5.ExecuteScalar(); cdf.Close(); yearst = yerstart.SelectedValue; mounthst = monstart.SelectedValue; dayst = daystart.SelectedValue; datestart = yearst + "/" + mounthst + "/" + dayst; lstart.Text = datestart; lstartprint.Text = lstart.Text; lfinishprintstart.Text = lstart.Text; yearfin = yerfin.SelectedValue; mounthfin = monfin.SelectedValue; dayfini = dayfin.SelectedValue; datefinish = yearfin + "/" + mounthfin + "/" + dayfini; lfinish.Text = datefinish; lfinishprint.Text = lfinish.Text; cdf.Open(); SqlDataSource10.SelectCommand = "SELECT TOP (100) PERCENT flow_info.nam_f, flow_info.cod_f, flow_info.date_first_come, flow_info.customer_f, SUM(arrange_gol.remain_barg) AS input, SUM(arrange_gol.remain_barg) AS remain, flow_info.id, flow_info.color_f, flow_info.type_color, flow_info.typ_f FROM flow_info INNER JOIN arrange_gol ON flow_info.id = arrange_gol.id_gol WHERE (flow_info.date_first_come BETWEEN '1375/01/01' AND '" + lstart.Text + "') AND (flow_info.customer_f_id = " + ddlcustomer.SelectedValue + ") GROUP BY flow_info.nam_f, flow_info.cod_f, flow_info.date_first_come, flow_info.customer_f, flow_info.id, flow_info.color_f, flow_info.type_color, flow_info.typ_f ORDER BY flow_info.date_first_come,flow_info.nam_f"; dv = (System.Data.DataView)SqlDataSource10.Select(DataSourceSelectArguments.Empty); count = dv.Count; if (dv.Count != 0) { for (int i = 0; i < count; i++) { idgol = Convert.ToInt32(dv.ToTable().Rows[i]["id"]); cdf.Close(); cdf.Open(); SqlCommand selectid = new SqlCommand("INSERT INTO help_rep_cus(idgol,namgol,colorgol,typegol,firstcom,remain,a10070,a2535,a4060,a5070,a5271,a6080,a6585,a7182,a4) " + " SELECT (" + idgol + ") AS 'idgol', " + " (SELECT nam_f AS namf FROM dbo.flow_info AS flow_info_10 " + " WHERE (customer_f_id = " + ddlcustomer.SelectedValue + ") AND (id = " + idgol + ")) AS 'nam_gol' " + " , (SELECT color_f AS color FROM dbo.flow_info WHERE (customer_f_id = " + ddlcustomer.SelectedValue + ") AND (id = " + idgol + ")) AS 'color_gol', " + " (SELECT typ_f AS AStype FROM dbo.flow_info AS flow_info_12 WHERE (customer_f_id = " + ddlcustomer.SelectedValue + ") AND (id = " + idgol + ")) AS 'type_gol' " + " ,(SELECT date_first_come AS come FROM dbo.flow_info AS flow_info_11 WHERE (customer_f_id = " + ddlcustomer.SelectedValue + ") " + " AND (id = " + idgol + ")) AS 'first_come',(SELECT case when SUM(remain_barg)>0 then SUM(remain_barg) else 0 " + " end AS remain FROM dbo.arrange_gol WHERE (id_gol = " + idgol + ")) AS 'remain_barg', " + " (SELECT case when SUM(arrange_gol_9.remain_barg)>0 then SUM(arrange_gol_9.remain_barg) else 0 end AS Expr1 " + " FROM dbo.flow_info AS flow_info_9 INNER JOIN dbo.arrange_gol AS arrange_gol_9 ON flow_info_9.id = arrange_gol_9.id_gol " + " WHERE (flow_info_9.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_9.dim_arr_f = 1) " + " AND (flow_info_9.id = " + idgol + ")) AS '100*70',(SELECT case when SUM(arrange_gol_1.remain_barg)>0 then " + " SUM(arrange_gol_1.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info AS flow_info_1 INNER JOIN dbo.arrange_gol " + " AS arrange_gol_1 ON flow_info_1.id = arrange_gol_1.id_gol WHERE (flow_info_1.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_1.dim_arr_f = 2) " + " AND (flow_info_1.id = " + idgol + ")) AS '25*35', (SELECT case when SUM(arrange_gol_2.remain_barg)>0 " + " then SUM(arrange_gol_2.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info AS flow_info_2 INNER JOIN dbo.arrange_gol " + " AS arrange_gol_2 ON flow_info_2.id = arrange_gol_2.id_gol WHERE (flow_info_2.customer_f_id = " + ddlcustomer.SelectedValue + ") AND " + " (arrange_gol_2.dim_arr_f = 3) AND (flow_info_2.id = " + idgol + ")) AS '40*60',(SELECT case when " + " SUM(arrange_gol_8.remain_barg)>0 then SUM(arrange_gol_8.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info " + " AS flow_info_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON flow_info_8.id = arrange_gol_8.id_gol WHERE (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_8.dim_arr_f = 4) " + " AND (flow_info_8.id = " + idgol + ")) AS '50*70', (SELECT case when SUM(arrange_gol_7.remain_barg)>0 then " + " SUM(arrange_gol_7.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info AS flow_info_7 INNER JOIN dbo.arrange_gol " + " AS arrange_gol_7 ON flow_info_7.id = arrange_gol_7.id_gol WHERE (flow_info_7.customer_f_id = " + ddlcustomer.SelectedValue + ") AND " + " (arrange_gol_7.dim_arr_f = 5) AND (flow_info_7.id = " + idgol + ")) AS '52*71', " + " (SELECT case when SUM(arrange_gol_6.remain_barg)>0 then SUM(arrange_gol_6.remain_barg) else 0 end AS Expr1 " + " FROM dbo.flow_info AS flow_info_6 INNER JOIN dbo.arrange_gol AS arrange_gol_6 ON flow_info_6.id = arrange_gol_6.id_gol WHERE " + " (flow_info_6.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_6.dim_arr_f = 6) AND " + " (flow_info_6.id = " + idgol + ")) AS '60*80',(SELECT case when SUM(arrange_gol_5.remain_barg)>0 then " + " SUM(arrange_gol_5.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info AS flow_info_5 INNER JOIN dbo.arrange_gol AS " + " arrange_gol_5 ON flow_info_5.id = arrange_gol_5.id_gol WHERE (flow_info_5.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_5.dim_arr_f = 7) AND " + " (flow_info_5.id = " + idgol + ")) AS '65*85',(SELECT case when SUM(arrange_gol_4.remain_barg)>0 then " + " SUM(arrange_gol_4.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info AS flow_info_4 INNER JOIN dbo.arrange_gol AS " + " arrange_gol_4 ON flow_info_4.id = arrange_gol_4.id_gol WHERE (flow_info_4.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_4.dim_arr_f = 8) AND " + " (flow_info_4.id = " + idgol + ")) AS '71*82',(SELECT case when SUM(arrange_gol_3.remain_barg)>0 then " + " SUM(arrange_gol_3.remain_barg) else 0 end AS Expr1 FROM dbo.flow_info AS flow_info_3 INNER JOIN dbo.arrange_gol AS arrange_gol_3 " + " ON flow_info_3.id = arrange_gol_3.id_gol WHERE (flow_info_3.customer_f_id = " + ddlcustomer.SelectedValue + ") AND (arrange_gol_3.dim_arr_f = 9) AND " + " (flow_info_3.id = " + idgol + ")) AS 'A4' ", cdf); selectid.ExecuteScalar(); } } cdf.Close(); cdf.Open(); SqlCommand inser = new SqlCommand("INSERT INTO help_repcus_tarikh ([a10070],[a2535],[a4060],[a5070],[a5271],[a6080],[a6585],[a7182],[a4]) " + " SELECT CASE WHEN SUM(a10070) IS NULL THEN 0 ELSE SUM(a10070) END ,CASE WHEN SUM(a2535) IS NULL THEN 0 ELSE SUM(a2535) END " + " ,CASE WHEN SUM(a4060) IS NULL THEN 0 ELSE SUM(a4060) END ,CASE WHEN SUM(a5070) IS NULL THEN 0 ELSE SUM(a5070) END " + " ,CASE WHEN SUM(a5271) IS NULL THEN 0 ELSE SUM(a5271) END ,CASE WHEN SUM(a6080) IS NULL THEN 0 ELSE SUM(a6080) END " + " ,CASE WHEN SUM(a6585) IS NULL THEN 0 ELSE SUM(a6585) END ,CASE WHEN SUM(a7182) IS NULL THEN 0 ELSE SUM(a7182) END " + " ,CASE WHEN SUM(a4) IS NULL THEN 0 ELSE SUM(a4) END FROM help_rep_cus ", cdf); inser.ExecuteScalar(); SqlCommand inserttt = new SqlCommand("INSERT INTO [depogol].[dbo].[help_repcus2] " + " ([a10070] ,[a2535] ,[a4060] ,[a5070] ,[a5271] ,[a6080] ,[a6585] ,[a7182] ,[a4]) " + " SELECT (SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a10070 " + " FROM dbo.help_repcus_tarikh) AS amount,(SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON " + " sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 1) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total) AS a10070, " + " (SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a2535 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount,(SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE " + " SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 2) " + " AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8) AS a2535,(SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total " + " FROM (SELECT (SELECT a4060 FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 3) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1) " + " AS a4060, (SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a5070 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 4) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1_6) " + " AS a5070, (SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a5271 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount,(SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 5) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1_5) " + " AS a5271, (SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a6080 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 6) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1_4) " + " AS a6080,(SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a6585 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 7) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1_3) " + " AS a6585,(SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a7182 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount,(SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 8) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1_2) " + " AS a7182,(SELECT CASE WHEN subsum >= 0 THEN (amount - subsum) ELSE amount + (- subsum) END AS total FROM (SELECT (SELECT a4 " + " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount,(SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 9) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS subsum) AS total_8_1_1) AS a4", cdf); inserttt.ExecuteScalar(); SqlCommand insertha = new SqlCommand("INSERT INTO [depogol].[dbo].[help_repcus_now] " + " ([a10070] ,[a2535] ,[a4060] ,[a5070] ,[a5271] ,[a6080] ,[a6585] ,[a7182] ,[a4]) " + " SELECT (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 1) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a10070, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 2) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a2535, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 3) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a4060, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 4) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a5070, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 5) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a5271, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 6) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a6080, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 7) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a6585, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 8) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a7182, " + " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + " WHERE (sub_arrange_8.datee BETWEEN '" + lstartprint.Text + "' AND '" + lfinishprint.Text + "') AND (arrange_gol_8.dim_arr_f = 9) AND (flow_info_8.customer_f_id = " + ddlcustomer.SelectedValue + ")) AS a4", cdf); insertha.ExecuteScalar(); SqlCommand inserthaa = new SqlCommand("INSERT INTO help_3 SELECT * FROM help_repcus_tarikh", cdf); inserthaa.ExecuteScalar(); SqlCommand updaaat = new SqlCommand("UPDATE [depogol].[dbo].[help_repcus_now] SET [a10070] = case when a10070 < 0 then 0 else a10070 end " + " ,[a2535] = case when a2535 < 0 then 0 else a2535 end ,[a4060] = case when a4060 < 0 then 0 else a4060 end ,[a5070] = case when a5070 < 0 then 0 else a5070 end " + " ,[a5271] = case when a5271 < 0 then 0 else a5271 end ,[a6080] = case when a6080 < 0 then 0 else a6080 end ,[a6585] = case when a6585 < 0 then 0 else a6585 end " + " ,[a7182] = case when a7182 < 0 then 0 else a7182 end ,[a4] = case when a4 < 0 then 0 else a4 end ", cdf); updaaat.ExecuteScalar(); /* * * SqlCommand updat = new SqlCommand("UPDATE hrt SET hrt.a10070 = case when hr2.a10070 < 0 then hrt.a10070 + hr2.a10070 else hrt.a10070 end " + * " ,hrt.a2535 = case when hr2.a2535 < 0 then hrt.a2535 + hr2.a2535 else hrt.a2535 + hr2.a2535 end " + * " ,hrt.a4060 = case when hr2.a4060 < 0 then hrt.a4060 + hr2.a4060 else hrt.a4060 + hr2.a4060 end " + * " ,hrt.a5070 = case when hr2.a5070 < 0 then hrt.a5070 + hr2.a5070 else hrt.a5070 + hr2.a5070 end " + * " ,hrt.a5271 = case when hr2.a5271 < 0 then hrt.a5271 + hr2.a5271 else hrt.a5271 + hr2.a5271 end " + * " ,hrt.a6080 = case when hr2.a6080 < 0 then hrt.a6080 + hr2.a6080 else hrt.a6080 + hr2.a6080 end " + * " ,hrt.a6585 = case when hr2.a6585 < 0 then hrt.a6585 + hr2.a6585 else hrt.a6585 + hr2.a6585 end " + * " ,hrt.a7182 = case when hr2.a7182 < 0 then hrt.a7182 + hr2.a7182 else hrt.a7182 + hr2.a7182 end " + * " ,hrt.a4 = case when hr2.a4 < 0 then hrt.a4 + hr2.a4 else hrt.a4 + hr2.a4 end " + * " from help_repcus_tarikh hrt , help_repcus2 hr2 ", cdf); * updat.ExecuteScalar(); * SqlCommand updata = new SqlCommand("UPDATE help_repcus2 SET a10070 = case when a10070 < 0 then 0 else a10070 end " + * " ,a2535 = case when a2535 < 0 then 0 else a2535 end ,a4060 = case when a4060 < 0 then 0 else a4060 end " + * " ,a5070 = case when a5070 < 0 then 0 else a5070 end ,a5271 = case when a5271 < 0 then 0 else a5271 end " + * " ,a6080 = case when a6080 < 0 then 0 else a6080 end ,a6585 = case when a6585 < 0 then 0 else a6585 end " + * " ,a7182 = case when a7182 < 0 then 0 else a7182 end ,a4 = case when a4 < 0 then 0 else a4 end " + * " from help_repcus2 ", cdf); * updata.ExecuteScalar(); */ /* SqlCommand inserttt = new SqlCommand("INSERT INTO [depogol].[dbo].[help_repcus2] "+ * " ([a10070] ,[a2535] ,[a4060] ,[a5070] ,[a5271] ,[a6080] ,[a6585] ,[a7182] ,[a4]) "+ * " SELECT (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a10070 " + * " FROM dbo.help_repcus_tarikh) AS amount,(SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + * " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + * " WHERE (sub_arrange_8.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_8.dim_arr_f = 1) AND (flow_info_8.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total) " + * " AS a10070, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a2535 FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_8) AS amount, " + * " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN " + * " dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + * " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + * " WHERE (sub_arrange_8.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_8.dim_arr_f = 2) AND (flow_info_8.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_8) " + * " AS a2535, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a4060 " + * " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_7) AS amount, (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + * " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id WHERE (sub_arrange_8.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_8.dim_arr_f = 3) " + * " AND (flow_info_8.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_7) AS a4060, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a5070 FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_6) AS amount, " + * " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + * " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + * " WHERE (sub_arrange_8.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_8.dim_arr_f = 4) AND (flow_info_8.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_6) " + * " AS a5070, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a5271 " + * " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_5) AS amount, (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + * " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id WHERE (sub_arrange_8.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_8.dim_arr_f = 5) AND " + * " (flow_info_8.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_5) AS a5271, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a6080 FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_4) AS amount, " + * " (SELECT CASE WHEN SUM(sub_arrange_8.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_8.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_8 INNER JOIN dbo.arrange_gol AS arrange_gol_8 ON sub_arrange_8.arrange_cod_f = arrange_gol_8.id INNER JOIN " + * " dbo.flow_info AS flow_info_8 ON arrange_gol_8.id_gol = flow_info_8.id " + * " WHERE (sub_arrange_8.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_8.dim_arr_f = 6) AND (flow_info_8.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_4) " + * " AS a6080, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a6585 FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_3) AS amount, " + * " (SELECT CASE WHEN SUM(sub_arrange_3.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_3.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_3 INNER JOIN dbo.arrange_gol AS arrange_gol_3 ON sub_arrange_3.arrange_cod_f = arrange_gol_3.id INNER JOIN " + * " dbo.flow_info AS flow_info_3 ON arrange_gol_3.id_gol = flow_info_3.id " + * " WHERE (sub_arrange_3.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_3.dim_arr_f = 7) AND (flow_info_3.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_3) " + * " AS a6585, (SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a7182 FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_2) AS amount, " + * " (SELECT CASE WHEN SUM(sub_arrange_2.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_2.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_2 INNER JOIN dbo.arrange_gol AS arrange_gol_2 ON sub_arrange_2.arrange_cod_f = arrange_gol_2.id INNER JOIN " + * " dbo.flow_info AS flow_info_2 ON arrange_gol_2.id_gol = flow_info_2.id " + * " WHERE (sub_arrange_2.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_2.dim_arr_f = 8) AND (flow_info_2.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_2) " + * " AS a7182,(SELECT CASE WHEN subsum >= 0 THEN (amount + subsum) ELSE CASE WHEN (- subsum) > amount THEN amount ELSE amount - (- 1 * subsum) END END AS total "+ * " FROM (SELECT (SELECT a4 " + * " FROM dbo.help_repcus_tarikh AS help_repcus_tarikh_1) AS amount,(SELECT CASE WHEN SUM(sub_arrange_1.remain) IS NULL THEN 0 ELSE SUM(sub_arrange_1.remain) END AS summ " + * " FROM dbo.sub_arrange AS sub_arrange_1 INNER JOIN dbo.arrange_gol AS arrange_gol_1 ON sub_arrange_1.arrange_cod_f = arrange_gol_1.id INNER JOIN " + * " dbo.flow_info AS flow_info_1 ON arrange_gol_1.id_gol = flow_info_1.id " + * " WHERE (sub_arrange_1.datee BETWEEN '"+lstartprint.Text+"' AND '"+lfinishprint.Text+"') AND (arrange_gol_1.dim_arr_f = 9) AND (flow_info_1.customer_f_id = "+ddlcustomer.SelectedValue+")) AS subsum) AS total_1) AS a4", cdf); * inserttt.ExecuteScalar();*/ cdf.Close(); SqlDataSource1.DataBind(); SqlDataSource2.DataBind(); SqlDataSource3.DataBind(); gridrepcust.DataBind(); gridrepcusttarikh.DataBind(); staynow.DataBind(); gridrepcust.Visible = true; lcustomer.Text = Convert.ToString(ddlcustomer.SelectedItem); lcustomer2.Text = lcustomer.Text; lcustomer3.Text = lcustomer.Text; cdf.Open(); SqlCommand del6 = new SqlCommand("delete from help_rep_cus", cdf); del6.ExecuteScalar(); SqlCommand del7 = new SqlCommand("delete from help_repcus_tarikh", cdf); del7.ExecuteScalar(); SqlCommand del8 = new SqlCommand("delete from help_repcus2", cdf); del8.ExecuteScalar(); SqlCommand del9 = new SqlCommand("delete from help_repcus_now", cdf); del9.ExecuteScalar(); SqlCommand del10 = new SqlCommand("delete from help_3", cdf); del10.ExecuteScalar(); cdf.Close(); }
protected void DeptcodeTextChanged(object sender, EventArgs e) { try { User_Mangement v = new User_Mangement(); User b = new User(); User b1 = new User(); //b.UserId = null; //b.UserId = txtuserid.Text; b.User_Id = null; // b.User_Id = txtuserid.Text; b = v.selectExistingUser(txtuserid.Text.Trim()); if (b.User_Id != null) { lblActive.Visible = true; DropDownListactive.Visible = true; txtuserid.Text = b.User_Id; DropDownListPrefix.SelectedValue = b.UserNamePrefix; DropDownListPrefix.Enabled = false; TextBoxFname.Text = b.UserFirstName; TextBoxFname.Enabled = false; TextBoxMname.Text = b.UserMiddleName; TextBoxMname.Enabled = false; TextBoxLName.Text = b.UserLastName; TextBoxLName.Enabled = false; DDLinstitutename.SelectedValue = b.Institute_name; DDLinstitutename.Enabled = false; DropDownListactive.SelectedValue = b.Active; DropDownListactive.Enabled = false; DDLdeptname.Items.Clear(); SqlDataSource1.SelectParameters.Clear(); SqlDataSource1.SelectParameters.Add("Institute_Id", DDLinstitutename.SelectedValue); // DDLdeptname.Items.Add(new ListItem("--Select--", "", true)); SqlDataSource1.SelectCommand = "SELECT DISTINCT [DeptName], [DeptId] FROM [Dept_M] where Institute_Id =@Institute_Id"; SqlDataSource1.DataBind(); DDLdeptname.DataBind(); DDLdeptname.SelectedValue = b.Department; DDLdeptname.DataBind(); DDLdeptname.Enabled = false; txtemailid.Text = b.EmailId; Session["OldmailID"] = txtemailid.Text; if (txtemailid.Text == "" || txtemailid.Text == null) { txtemailid.Enabled = true; } else { txtemailid.Enabled = true; } //RBLautoapproval.Text = b.AutoApproved; //RBLautoapproval.Enabled = false; // SqlDataSource3.SelectCommand = ""; if (b.Role_Id == 5) {//librarian SqlDataSource3.SelectCommand = "SELECT DISTINCT [Role_Name], [Role_Id] FROM [Role_M] "; SqlDataSource3.DataBind(); DDLrolename.DataBind(); } else { // SqlDataSource3.SelectCommand = "SELECT DISTINCT [Role_Name], [Role_Id] FROM [Role_M] where Role_Id!=5"; // SqlDataSource3.DataBind(); //DDLrolename.DataBind(); } DDLrolename.SelectedValue = Convert.ToString(b.Role_Id); if (b.Role_Id == 1) { DDLrolename.Enabled = true; btnupdate.Enabled = true; RadioButtonListDeparmentPubincharge.Items.Clear(); string deptname = DDLdeptname.SelectedItem.ToString(); string deptvalue = DDLdeptname.SelectedValue; PubDept.Visible = true; RadioButtonListDeparmentPubincharge.Visible = true; RadioButtonListDeparmentPubincharge.Items.Add(new ListItem(deptname, deptvalue, true)); RadioButtonListDeparmentPubincharge.Items.Add(new ListItem("All Departments of Institute", "", true)); b1 = v.selectPubInchargeUM(txtuserid.Text.Trim()); RadioButtonListDeparmentPubincharge.SelectedValue = b1.Department_Id; RadioButtonListDeparmentPubincharge.DataBind(); } else if (b.Role_Id == 5) { //librarian DDLrolename.Enabled = false; btnupdate.Enabled = false; } else { DDLrolename.Enabled = true; btnupdate.Enabled = true; PubDept.Visible = false; RadioButtonListDeparmentPubincharge.Visible = false; RadioButtonListDeparmentPubincharge.Items.Clear(); } txtuserid.Enabled = false; btninsert.Enabled = false; // btnupdate.Enabled = true; popupPanelBaCode.Visible = false; ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert(' User exixts!')</script>"); } else { lblActive.Visible = false; DropDownListactive.Visible = false; btninsert.Enabled = true; btnupdate.Enabled = false; txtuserid.Enabled = false; popupPanelBaCode.Visible = false; ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert(' New User!')</script>"); } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); log.Error("Error!!!!!!!!!!!!!!!! "); if (ex.Message.Contains("DDLdeptname' has a SelectedValue which is invalid because it does not exist in the list of")) { ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!Institue_Department Map error!!!')</script>"); } else { ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Error!!!!!!!!!!')</script>"); } } }
/// <summary> /// Handles the Click event of the bAgregar control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void bAgregar_Click(object sender, EventArgs e) { var sql = ""; DbDataReader dr = null; if (string.IsNullOrEmpty(_idEditar)) { _db.Conectar(); _db.CrearComando("SELECT id FROM Cat_CatImpuestos_C WHERE codigo = @codigo"); _db.AsignarParametroCadena("@codigo", tbCodigo.Text); dr = _db.EjecutarConsulta(); if (dr.Read()) { _db.Desconectar(); (Master as SiteMaster).MostrarAlerta(this, "El impuesto con el código " + tbCodigo.Text + " ya esta registrado.", 4, null); return; } _db.Desconectar(); sql = @"INSERT INTO Cat_CatImpuestos_C (descripcion, valor, codigo, comentarios, tipo, tipoFactor, porcentajeBase) VALUES (@descripcion, @valor, @codigo, @comentarios, @tipo, @tipoFactor, @porcentajeBase)"; } else { _db.Conectar(); _db.CrearComando("SELECT id FROM Cat_CatImpuestos_C WHERE id <> @id AND codigo = @codigo"); _db.AsignarParametroCadena("@id", _idEditar); _db.AsignarParametroCadena("@codigo", tbCodigo.Text); dr = _db.EjecutarConsulta(); if (dr.Read()) { _db.Desconectar(); (Master as SiteMaster).MostrarAlerta(this, "El impuesto con el código " + tbCodigo.Text + " ya esta registrado.", 4, null); return; } _db.Desconectar(); sql = @"UPDATE Cat_CatImpuestos_C SET descripcion = @descripcion, valor = @valor, codigo = @codigo, comentarios = @comentarios, tipo = @tipo, tipoFactor = @tipoFactor, porcentajeBase = @porcentajeBase WHERE id=@id"; } try { if (Session["CfdiVersion"].ToString().Equals("3.3") && ddlImpuesto.Visible) { var catalogos = (CatCdfi)Session["CatalogosCfdi33"]; var existeImpuesto = catalogos.CImpuesto.Any(c => c.Value.Equals(tbImpuesto.Text.Trim(), StringComparison.OrdinalIgnoreCase)); var existeTasaCuota = catalogos.CTasaocuota.Any(c => c.Key.Equals(tbImpuesto.Text.Trim()) && c.Value.Split('-')[0].Equals(ddlTipoFactor.SelectedValue, StringComparison.OrdinalIgnoreCase) && decimal.Parse(CerosNull(tbValor.Text)) >= decimal.Parse(c.Value.Split('-')[1]) && decimal.Parse(CerosNull(tbValor.Text)) <= decimal.Parse(c.Value.Split('-')[2])); // Validations if (!existeImpuesto) { throw new Exception($"El impuesto {tbImpuesto.Text} no existe en el catálogo del SAT"); } else if (!existeTasaCuota) { throw new Exception($"La tasa del impuesto {tbImpuesto.Text} no está en el rango del catálogo del SAT"); } } _db.Conectar(); _db.CrearComando(sql); if (!string.IsNullOrEmpty(_idEditar)) { _db.AsignarParametroCadena("@id", _idEditar); } _db.AsignarParametroCadena("@descripcion", tbImpuesto.Text); _db.AsignarParametroCadena("@valor", CerosNull(tbValor.Text)); _db.AsignarParametroCadena("@codigo", tbCodigo.Text); _db.AsignarParametroCadena("@comentarios", tbDescripcion.Text); _db.AsignarParametroCadena("@tipo", ddlTipo.SelectedValue); _db.AsignarParametroCadena("@tipoFactor", ddlTipoFactor.SelectedValue); _db.AsignarParametroCadena("@porcentajeBase", tbBase.Text); _db.EjecutarConsulta1(); tbCodigo.Text = ""; tbImpuesto.Text = ""; tbValor.Text = ""; tbDescripcion.Text = ""; ddlTipo.SelectedValue = "0"; ddlTipoFactor.SelectedValue = "0"; (Master as SiteMaster).MostrarAlerta(this, "El impuesto se " + (!string.IsNullOrEmpty(_idEditar) ? "modificó" : "agregó") + " correctamente.", 2, null, "$('#divNuevo').modal('hide');"); } catch (Exception ex) { (Master as SiteMaster).MostrarAlerta(this, "El impuesto no se pudo agregar/modificar. Intentelo nuevamente.<br>" + ex.Message, 4, null); } _db.Desconectar(); SqlDataSource3.DataBind(); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["status"] != null && Session["status"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Multumim! Votul tau a fost inregistrat','success');", true); Session.Remove("status"); } if (Session["editBook"] != null && Session["editBook"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Date cartii au fost actualizate cu succes!','success');", true); Session.Remove("editBook"); } } catch (Exception err) { } if (!Page.IsPostBack) { string q = Request.Params["q"]; if (q != null) { try { q = Server.UrlDecode(q); SqlDataSource1.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Carti.Text_Descriere, Genuri.Gen, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, ROUND(AVG(ISNULL(NoteDateCartilor.Nota, 0)), 0) AS MedieNote FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id LEFT JOIN NoteDateCartilor ON Carti.Id = NoteDateCartilor.Id_Carte WHERE Carti.Id = @q GROUP BY Carti.Id, Carti.Titlu, Carti.Poza_Coperta, Carti.Text_Descriere, Genuri.Gen, Autori.Prenume + ' ' + Autori.Nume"; SqlDataSource1.SelectParameters.Clear(); SqlDataSource1.SelectParameters.Add("q", q); SqlDataSource1.DataBind(); bool check = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated; if (check) { string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); string sqlVerif = "SELECT count(*) from PozeUseri where Id_user = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { Image imagine = LoginView1.FindControl("ImgUserPicture2") as Image; imagine.ImageUrl = "~/pozeUseri/" + user + ".jpg"; } } SqlDataSource2.SelectCommand = "SELECT Comentarii.Id, Comentarii.Comentariu_Text, Comentarii.Data, Comentarii.Id_Carte, aspnet_Users.UserName, PozeUseri.Poza_User FROM aspnet_Users INNER JOIN Comentarii ON aspnet_Users.UserId = Comentarii.Id_User LEFT OUTER JOIN PozeUseri ON Comentarii.Id_User = PozeUseri.Id_User WHERE Comentarii.Id_Carte = @q"; SqlDataSource2.SelectParameters.Clear(); SqlDataSource2.SelectParameters.Add("q", q); SqlDataSource2.DataBind(); SqlDataSource3.SelectCommand = "SELECT TOP 10 Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id WHERE (Genuri.Gen = (SELECT Genuri_1.Gen FROM Genuri AS Genuri_1 INNER JOIN Carti AS Carti_1 ON Genuri_1.Id = Carti_1.Id_Gen WHERE (Carti_1.Id = @q))) AND (Carti.Id <> (SELECT Id FROM Carti AS Carti_2 WHERE (Id = @q))) ORDER BY NEWID()"; SqlDataSource3.SelectParameters.Clear(); SqlDataSource3.SelectParameters.Add("q", q); SqlDataSource3.DataBind(); SqlDataSource4.SelectCommand = "SELECT Edituri.Editura, Edituri.Site_Editura FROM CartiApartinDeEdituri INNER JOIN Edituri ON CartiApartinDeEdituri.Id_Editura = Edituri.Id INNER JOIN Carti ON CartiApartinDeEdituri.Id_Carte = Carti.Id WHERE Carti.Id = @q"; SqlDataSource4.SelectParameters.Clear(); SqlDataSource4.SelectParameters.Add("q", q); SqlDataSource4.DataBind(); } catch (Exception err) { } } else { Response.Redirect("~/Home.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { String ConnStr = "SERVER=" + ConfigurationManager.AppSettings["PIBASServer"] + ";USER ID=" + ConfigurationManager.AppSettings["PIBASUser"] + "; PWD =" + ConfigurationManager.AppSettings["PIBASpwd"]; OracleConnection myConnection = new OracleConnection(ConnStr); String strQuery = @"SELECT MA38.FTD_TYPE, " + " FTD_TYPE_DESC, " + "nvl(T_ACTIVE_NOC,0) as T_ACTIVE_NOC , " + " nvl( TOTAL_FACEVALUE,0) as TOTAL_FACEVALUE , " + " nvl( LAST_WORKDAY_NOAC,0) as LAST_WORKDAY_NOAC , " + " nvl(LAST_WORKDAY_FACEVALUE,0) as LAST_WORKDAY_FACEVALUE , " + " nvl(LAST_WORKDAY_MTRNOC,0) as LAST_WORKDAY_MTRNOC , " + " nvl(LAST_WORKDAY_FACEVALE,0) as LAST_WORKDAY_FACEVALE " + " FROM PLS.MA38 " + " LEFT OUTER JOIN " + " ( SELECT FTD_TYPE, " + " SUM (T_Active_NOC) T_ACTIVE_NOC, " + " SUM (Total_FaceValue) TOTAL_FACEVALUE, " + " SUM (Last_workday_NOAC) LAST_WORKDAY_NOAC, " + " SUM (Last_workday_Facevalue) LAST_WORKDAY_FACEVALUE, " + " SUM (Last_WorkDay_MtrNoc) LAST_WORKDAY_MTRNOC, " + " SUM (Last_WorkDay_FaceVale) LAST_WORKDAY_FACEVALE, " + " ( SELECT FTD_TYPE_DESC " + " FROM PLS.MA38 B " + " WHERE B.FTD_TYPE = XYZ.FTD_TYPE " + " GROUP BY FTD_TYPE_DESC) " + " DESC1 " + " FROM ( SELECT FTD_TYPE, " + " COUNT (*) T_ACTIVE_NOC, " + " SUM (DEAL_AMNT) TOTAL_FACEVALUE, " + " 0 LAST_WORKDAY_NOAC, " + " 0 LAST_WORKDAY_FACEVALUE, " + " 0 LAST_WORKDAY_MTRNOC, " + " 0 LAST_WORKDAY_FACEVALE " + " FROM PLS.MH A " + " WHERE FTD_TYPE IN (29, 30, 31) " + " AND STRT_DATE <= '31-jan-2016' " + " AND DEAL_RVSL_INDC <> 1 " + " AND DEAL_STAT = 0 " + "GROUP BY FTD_TYPE " + " UNION ALL " + " SELECT FTD_TYPE, " + " 0 T_ACTIVE_NOC, " + " 0 TOTAL_FACEVALUE, " + " COUNT (*) LAST_WORKDAY_NOAC, " + " SUM (DEAL_AMNT) LAST_WORKDAY_FACEVALUE, " + " 0 LAST_WORKDAY_MTRNOC, " + " 0 LAST_WORKDAY_FACEVALE " + "FROM PLS.MH A " + "WHERE FTD_TYPE IN (29, 30, 31) " + " AND STRT_DATE = '31-jan-2016' " + " AND DEAL_RVSL_INDC <> 1 " + " AND DEAL_STAT = 0 " + " GROUP BY FTD_TYPE " + "UNION ALL " + " SELECT FTD_TYPE, " + " 0 T_ACTIVE_NOC, " + " 0 TOTAL_FACEVALUE, " + " COUNT (*) LAST_WORKDAY_NOAC, " + " SUM (DEAL_AMNT) LAST_WORKDAY_FACEVALUE," + " COUNT (*) LAST_WORKDAY_MTRNOC," + " SUM (DEAL_AMNT) LAST_WORKDAY_FACEVALE" + " FROM PLS.MH A" + " WHERE FTD_TYPE IN (29, 30, 31)" + " AND STRT_DATE = '31-jan-2016'" + " AND DEAL_STAT = 1" + " GROUP BY FTD_TYPE) XYZ" + " GROUP BY FTD_TYPE) ABC" + " ON (MA38.FTD_TYPE = ABC.FTD_TYPE)" + " WHERE MA38.FTD_TYPE IN (31, 30, 29) and MA38.BRAN_CODE = 510" + " ORDER BY MA38.FTD_TYPE"; OracleDataAdapter adapter = new OracleDataAdapter(strQuery, ConnStr); DataSet Ds = new DataSet(); SqlDataSource1.SelectCommand = strQuery; GridView1.DataSource = SqlDataSource1; SqlDataSource1.DataBind(); GridView1.DataBind(); //current Products string strquery1 = "select max (AccountName) as AccountName , ACCT_TYPE ,max(ACCT_TYPE_DESC)as ACCT_TYPE_DESC , sum(counts) as counts , " + " sum(FaceValue) as FaceValue, sum( Active_count) as Active_count , sum(Active_sum) as Active_sum " + " from (select 'Current Account'as AccountName , md.ACCT_TYPE as ACCT_TYPE ,ma.ACCT_TYPE_DESC as ACCT_TYPE_DESC, " + " count(md.ACCT_TYPE) as counts , sum(md.LDGR_BALN) as FaceValue , 0 as Active_count , 0 as Active_sum " + " from pls.md md " + " left outer join pls.ma5 ma on md.ACCT_TYPE = ma.ACCT_TYPE and ma.BRAN_CODE = 510 " + " where md.ACCT_TYPE in (115,116,120) " + " group by md.ACCT_TYPE , ma.ACCT_TYPE_DESC " + " union " + " select 'Current Account' as AccountName , ACCT_TYPE ,'A' as ACCT_TYPE_DESC , 0 as counts , " + " 0 as FaceValue, count(*) as Active_count , sum(LDGR_BALN) as Active_sum " + " from pls.md where md.ACCT_CLSD_DATE is null and md.ACCT_TYPE in (115,116,120) group by ACCT_TYPE " + " )xyz " + " group by ACCT_TYPE "; SqlDataSource2.SelectCommand = strquery1; GridView2.DataSource = SqlDataSource2; SqlDataSource2.DataBind(); GridView2.DataBind(); // Saving Products string strquery2 = "select max (AccountName) as AccountName , ACCT_TYPE ,max(ACCT_TYPE_DESC)as ACCT_TYPE_DESC , sum(counts) as counts , " + " sum(FaceValue) as FaceValue, sum( Active_count) as Active_count , sum(Active_sum) as Active_sum " + " from (select 'Saving Account'as AccountName , md.ACCT_TYPE as ACCT_TYPE ,ma.ACCT_TYPE_DESC as ACCT_TYPE_DESC, " + " count(md.ACCT_TYPE) as counts , sum(md.LDGR_BALN) as FaceValue , 0 as Active_count , 0 as Active_sum " + " from pls.md md " + " left outer join pls.ma5 ma on md.ACCT_TYPE = ma.ACCT_TYPE and ma.BRAN_CODE = 510 " + " where md.ACCT_TYPE in (136,137,139) " + " group by md.ACCT_TYPE , ma.ACCT_TYPE_DESC " + " union " + " select 'Saving Account' as AccountName , ACCT_TYPE ,'A' as ACCT_TYPE_DESC , 0 as counts , " + " 0 as FaceValue, count(*) as Active_count , sum(LDGR_BALN) as Active_sum " + " from pls.md where md.ACCT_CLSD_DATE is null and md.ACCT_TYPE in (136,137,139) group by ACCT_TYPE " + " )xyz " + " group by ACCT_TYPE "; SqlDataSource3.SelectCommand = strquery2; GridView3.DataSource = SqlDataSource3; SqlDataSource3.DataBind(); GridView3.DataBind(); // SqlConnection OC= new SqlConnection(ConnStr); // if (OC.State == ConnectionState.Closed) { OC.Open(); } // SqlCommand ocOM = new SqlCommand(strQuery,OC ); // SqlDataReader ORR = ocOM.ExecuteReader(); // Chart1.DataBindTable(ORR, "FTD_TYPE_DESC"); // //DataTable dt = (DataTable)SqlDataSource1; // // Chart1.DataSource = SqlDataSource1; // // Chart1.DataSourceID = "FTD_TYPE_DESC"; ////Chart1.DataSource = SqlDataSource1; // // Chart1.DataBindTable(dataSource: "SqlDataSource1", xField: "FTD_TYPE"); // // Chart1.Write(); }
protected void Button9_Click(object sender, EventArgs e) { SqlDataSource3.SelectCommand = "SELECT Rubro.ID_Rubro, Rubro.Rubro, Rubro.ID_Modelo, Modelo.Modelo FROM Rubro INNER JOIN Modelo ON Rubro.ID_Modelo = Modelo.ID_Modelo WHERE Rubro like '%" + TextBox1.Text + "%' ORDER BY [Rubro]"; SqlDataSource3.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theUserId = theUserManager.getUserId(); programcode = "ssd1041"; if (!IsPostBack) { List<ProductLineEntity> user_plines = ProductLineFactory.GetByUserID(theUserManager.getUserId(), programcode); ASPxComboBoxPline.DataSource = user_plines; ASPxComboBoxPline.TextField = "PLINE_NAME"; ASPxComboBoxPline.ValueField = "PLINE_CODE"; ASPxComboBoxPline.DataBind(); ASPxComboBoxPline.SelectedIndex = 0; List<ProductLineEntity> plines = ProductLineFactory.GetAll(); ASPxComboBoxProcess.DataSource = plines; ASPxComboBoxProcess.TextField = "PLINE_NAME"; ASPxComboBoxProcess.ValueField = "PLINE_CODE"; ASPxComboBoxProcess.DataBind(); ASPxComboBoxProcess.Value = ASPxComboBoxPline.Value; //string sql = "select ALINE_CODE,ALINE_NAME from atpu_acrossline"; //dc.setTheSql(sql); //ASPxComboBoxAcross.DataSource = dc.GetTable(); //ASPxComboBoxAcross.TextField = "ALINE_NAME"; //ASPxComboBoxAcross.ValueField = "ALINE_CODE"; //ASPxComboBoxAcross.DataBind(); //ASPxComboBoxAcross.SelectedIndex = 0; string sql = "select * from code_station t left join code_station_type a on t.station_type=a.station_type_code where a.station_type_name like '%拆解%' and t.pline_code in (select pline_code from rel_user_pline where user_id='" + theUserManager.getUserId() + "') "; dc.setTheSql(sql); CJZD.DataSource = dc.GetTable(); CJZD.TextField = "STATION_NAME"; CJZD.ValueField = "STATION_TYPE"; CJZD.DataBind(); CJZD.SelectedIndex = 0; ASPxDateEdit1.Date = DateTime.Now; ASPxDateEdit2.Date = DateTime.Now.AddDays(5); ASPxBeginDate.Date = DateTime.Now; ASPxEndDate.Date = DateTime.Now.AddDays(5); } if (Request["opFlag"] == "getEditSeries") { string str1 = ""; string so = Request["SO"].ToString(); string sql = "select jx,config from copy_engine_property where SO='" + so.ToUpper() + "'"; dc.setTheSql(sql); if (dc.GetTable().Rows.Count == 0) { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } string config1 = dc.GetTable().Rows[0][1].ToString(); string jx1 = dc.GetTable().Rows[0][0].ToString(); if (jx1 == "") { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } if (jx1.EndsWith("ZZ")) { jx1 = jx1.Substring(0, jx1.Length - 2); } str1 = jx1; sql = "select GET_CSKD('" + so + "') from dual"; dc.setTheSql(sql); string bz1 = dc.GetValue().ToString(); str1 = str1 + "," + bz1; this.Response.Write(str1); this.Response.End(); } string plineSql = "SELECT a.PLINE_CODE,a.PLINE_NAME FROM CODE_PRODUCT_LINE a left join rel_user_pline b on a.rmes_id=b.PLINE_CODE " + " WHERE a.COMPANY_CODE='" + theCompanyCode + "' AND b.USER_ID='" + theUserId + "' order by a.pline_code"; SqlDataSource1.SelectCommand = plineSql; SqlDataSource1.DataBind(); string plineSql1 = "SELECT ALINE_CODE,ALINE_NAME FROM atpu_acrossline "; SqlDataSource2.SelectCommand = plineSql1; SqlDataSource2.DataBind(); string plineSql2 = "select * from code_station t left join code_station_type a on t.station_type=a.station_type_code where a.station_type_name like '%拆解%' and t.pline_code in (select pline_code from rel_user_pline where user_id='" + theUserManager.getUserId() + "') "; SqlDataSource3.SelectCommand = plineSql2; SqlDataSource3.DataBind(); setCondition(); }
/// <summary> /// Binds the conceptos. /// </summary> protected void BindConceptos() { SqlDataSource3.SelectCommand = "SELECT idConcepto, codigo, descripcion, valorUnitario, claveProdServ FROM Cat_CatConceptos_C WHERE idCategoria = '" + ddlCategorias.SelectedValue + "'"; SqlDataSource3.DataBind(); GridView1.DataBind(); }
protected void ASPxGridView12_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { SqlDataSource3.DataBind(); ASPxGridView2.DataBind(); }
protected void filter_SelectedIndexChanged(object sender, EventArgs e) { String query = "Select * from aspnet_Membership inner join aspnet_Users on aspnet_Membership.UserId = aspnet_Users.UserId inner join Artwork on aspnet_Membership.UserId = Artwork.artistID where "; int counter = 0; if (!ddlCategory.SelectedItem.Text.Equals("Select a category")) { if (counter == 0) { query += "Artwork.artworkCategory ='" + ddlCategory.Text + "' "; counter = 2; } else { query += "and Artwork.artworkCategory ='" + ddlCategory.Text + "' "; } } if (!ddlPrice.SelectedItem.Text.Equals("Select a price range")) { if (counter == 0) { if (ddlPrice.SelectedItem.Text.Equals("Less than 100")) { query += "Artwork.artworkPrice <100 "; counter = 2; } else if (ddlPrice.SelectedItem.Text.Equals("Between 100 and 500")) { query += "Artwork.artworkPrice between 100 and 500 "; counter = 2; } else if (ddlPrice.SelectedItem.Text.Equals("Between 501 and 1000")) { query += "Artwork.artworkPrice between 501 and 1000 "; counter = 2; } else { query += "Artwork.artworkPrice >1000 "; counter = 2; } } else { if (ddlPrice.SelectedItem.Text.Equals("Less than 100")) { query += "and Artwork.artworkPrice <100 "; counter = 2; } else if (ddlPrice.SelectedItem.Text.Equals("Between 100 and 500")) { query += "and Artwork.artworkPrice between 100 and 500 "; counter = 2; } else if (ddlPrice.SelectedItem.Text.Equals("Between 501 and 1000")) { query += "and Artwork.artworkPrice between 501 and 1000 "; counter = 2; } else { query += "and Artwork.artworkPrice > 1000 "; counter = 2; } } } if (!ddlArtist.SelectedItem.Text.Equals("Select an artist")) { if (counter == 0) { query += "aspnet_Users.UserName ='******' "; counter = 2; } else { query += "and aspnet_Users.UserName ='******' "; counter = 2; } } if (counter == 0) { query = "Select * from Artwork "; } SqlDataSource3.SelectCommand = query; SqlDataSource3.DataBind(); Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theUserId = theUserManager.getUserId(); theUserName = theUserManager.getUserName(); theUserCode = theUserManager.getUserCode(); theProgramCode = "atpu1C00"; //初始化站点名称begin if (Request["opFlag"] == "getEditZD") { string str1 = ""; string zdmc = Request["zddmC"].ToString(); string sql = "select STATION_CODE from CODE_STATION where STATION_NAME='" + zdmc + "'"; dc.setTheSql(sql); if (dc.GetTable().Rows.Count == 0) { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } string zddm = dc.GetTable().Rows[0][0].ToString(); if (zdmc == "") { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } str1 = zddm; this.Response.Write(str1); this.Response.End(); } //初始化站点名称end //初始化零件名称begin if (Request["opFlag"] == "getEditLJDM") { string str1 = ""; string ljdm = Request["ljdmC"].ToString(); string sql = "select PT_DESC2 from COPY_PT_MSTR where PT_PART='" + ljdm + "'"; dc.setTheSql(sql); if (dc.GetTable().Rows.Count == 0) { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } string ljmc = dc.GetTable().Rows[0][0].ToString(); if (ljdm == "") { str1 = ""; this.Response.Write(str1); this.Response.End(); return; } str1 = ljmc; this.Response.Write(str1); this.Response.End(); } //初始化零件名称end if (Request["opFlag"] == "getEditSeries") { string str = ""; string pcode = Request["PCode"].ToString().Trim(); //dataConn theDataConn = new dataConn(" select FUNC_GET_PLANSITE('" + pcode + "','D')from dual"); //theDataConn.OpenConn(); //string gQadSite = theDataConn.GetValue(); //if (gQadSite != "") //{ string sql = "SELECT distinct STATION_NAME FROM CODE_STATION where PLINE_CODE=RH_GET_DATA('L','" + pcode + "','','','')"; Session["1C00STATION"] = sql; SqlDataSource2.SelectCommand = sql; SqlDataSource2.DataBind(); //} this.Response.Write(str); this.Response.End(); } setCondition(); //string Sql2 = "SELECT distinct STATION_NAME FROM CODE_STATION order by STATION_NAME "; //SqlDataSource2.SelectCommand = Sql2; //SqlDataSource2.DataBind(); //SqlDataSource22.SelectCommand = Sql2; //SqlDataSource22.DataBind(); string Sql3 = "SELECT distinct PT_PART,PT_DESC2 FROM COPY_PT_MSTR where pt_phantom=0 order by PT_PART "; SqlDataSource3.SelectCommand = Sql3; SqlDataSource3.DataBind(); string Sql4 = "select a.pline_code,b.rmes_id,b.pline_name from VW_USER_ROLE_PROGRAM a " + "left join code_product_line b on a.pline_code=b.pline_code " + "where a.COMPANY_CODE = '" + theCompanyCode + "' and a.user_id='" + theUserId + "' and a.program_code='" + theProgramCode + "' order by b.PLINE_NAME"; SqlDataSource4.SelectCommand = Sql4; SqlDataSource4.DataBind(); string Sql8 = "select internal_code,internal_name from code_internal " + "where COMPANY_CODE = '" + theCompanyCode + "' and internal_type_code='011' order by internal_code"; SqlLJLB.SelectCommand = Sql8; SqlLJLB.DataBind(); //if (!IsPostBack) //{ // string sql = "SELECT distinct STATION_NAME FROM CODE_STATION "; // Session["1C00STATION"] = sql; // SqlDataSource2.SelectCommand = sql; // SqlDataSource2.DataBind(); //} }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["status"] != null && Session["status"].ToString().Equals("1")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Datele au fost actualizate cu succes!','success');", true); Session.Remove("status"); } } catch (Exception err) { } if (!Page.IsPostBack) { try { MembershipUser userCheck = System.Web.Security.Membership.GetUser(); if (userCheck != null) // bool userCheck = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated; // if (userCheck) { string username = System.Web.Security.Membership.GetUser().UserName.ToString(); string email = System.Web.Security.Membership.GetUser().Email.ToString(); string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); Username.Text = username; Email.Text = email; string sqlVerif = "SELECT count(*) from PozeUseri where Id_User = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { string sql = "SELECT Poza_User FROM PozeUseri WHERE Id_User = @IdUser"; con = ConnectionFactory.getNewSqlConnection(); con.Open(); com = new SqlCommand(sql, con); com.Parameters.AddWithValue("IdUser", user); try { SqlDataReader r = com.ExecuteReader(); while (r.Read()) { UserImage.ImageUrl = "~/pozeUseri/" + r["Poza_User"].ToString(); } } catch (Exception err) { } con.Close(); } else { UserImage.Attributes["src"] = "pozeUseri/DefaultUserIcon.png"; } string userId = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); SqlDataSource3.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiFavorite ON Carti.Id = CartiFavorite.Id_Carte WHERE CartiFavorite.Id_User = @user"; SqlDataSource3.SelectParameters.Clear(); SqlDataSource3.SelectParameters.Add("user", userId); SqlDataSource3.DataBind(); SqlDataSource4.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiDeCitit ON Carti.Id = CartiDeCitit.Id_Carte WHERE CartiDeCitit.Id_User = @user"; SqlDataSource4.SelectParameters.Clear(); SqlDataSource4.SelectParameters.Add("user", userId); SqlDataSource4.DataBind(); SqlDataSource5.SelectCommand = "SELECT Carti.Id AS CartiId, Carti.Titlu AS CartiTitlu, Carti.Poza_Coperta, Autori.Prenume + ' ' + Autori.Nume AS NumeAutor, Genuri.Gen FROM Carti INNER JOIN Genuri ON Carti.Id_Gen = Genuri.Id INNER JOIN Autori ON Carti.Id_Autor = Autori.Id INNER JOIN CartiCitite ON Carti.Id = CartiCitite.Id_Carte WHERE CartiCitite.Id_User = @user"; SqlDataSource5.SelectParameters.Clear(); SqlDataSource5.SelectParameters.Add("user", userId); SqlDataSource5.DataBind(); } else { Response.Redirect("~/Home.aspx", false); } } catch (Exception err) { } } if (IsPostBack && UserProfilePicture.PostedFile != null) { try { if (UserProfilePicture.HasFile) { String type = UserProfilePicture.PostedFile.ContentType.ToLower(); System.Drawing.Image img = System.Drawing.Image.FromStream(UserProfilePicture.PostedFile.InputStream); int height = img.Height; int width = img.Width; decimal size = Math.Round(((decimal)UserProfilePicture.PostedFile.ContentLength / (decimal)1024), 2); if (size > 3500) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Imagine prea mare! Dimensiunea maxima pentru imagine este 3,5MB.', 'danger');", true); } else { if (type.Contains("jpg") || type.Contains("jpeg")) { string user = System.Web.Security.Membership.GetUser().ProviderUserKey.ToString(); UserProfilePicture.SaveAs(Server.MapPath("~/pozeUseri/") + user + ".jpg"); string sqlVerif = "SELECT count(*) from PozeUseri where Id_User = @IdUser"; SqlConnection con = ConnectionFactory.getNewSqlConnection(); con.Open(); SqlCommand com = new SqlCommand(sqlVerif, con); com.Parameters.AddWithValue("IdUser", user); int userCount = (int)com.ExecuteScalar(); con.Close(); if (userCount > 0) { string sql = "UPDATE PozeUseri SET Poza_User = @Poza WHERE Id_User = @IdUser"; con = ConnectionFactory.getNewSqlConnection(); con.Open(); com = new SqlCommand(sql, con); com.Parameters.AddWithValue("IdUser", user); string urlPoza = user + ".jpg"; com.Parameters.AddWithValue("Poza", urlPoza); com.ExecuteNonQuery(); con.Close(); UserImage.ImageUrl = "~/pozeUseri/" + urlPoza; } else { string sql = "INSERT INTO PozeUseri (Id_User, Poza_User) VALUES (@IdUser, @Poza)"; con = ConnectionFactory.getNewSqlConnection(); con.Open(); com = new SqlCommand(sql, con); com.Parameters.AddWithValue("IdUser", user); string urlPoza = user + ".jpg"; com.Parameters.AddWithValue("Poza", urlPoza); com.ExecuteNonQuery(); con.Close(); UserImage.ImageUrl = "~/pozeUseri/" + urlPoza; } //Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorFunction", "errorMessages('Imaginea au fost actualizata cu succes!','success');", true); //Session.Remove("status"); Session["status"] = "1"; Response.Redirect(Request.RawUrl, false); } //Response.Redirect(Request.RawUrl); //Server.TransferRequest(Request.Url.AbsolutePath, false); } } } catch (Exception err) { } } }