protected void InsertOrder_Info() { #region Order_Info Order_Info _Order_Info = new Order_Info(); _Order_Info.Order = int.Parse(ddlOrder.SelectedValue); _Order_Info.No_Order = int.Parse(txtNoOfOrders.Text); _Order_Info.Style = int.Parse(ddlStyle.SelectedValue); _Order_Info.Size = int.Parse(ddlSize.SelectedValue); _Order_Info.Description = txtDescription.Text; _Order_Info.DateString = txtDate.Text; _Order_Info.IsDeleted = false; #endregion lblMessage.Text = Order_Info_DA.InsertOrder_Info(_Order_Info); lblMessage.ForeColor = System.Drawing.Color.Green; Response.Write("<script>alert('Inserted Successfully'); document.location='/forms/formOrderInfo';</script>"); }
private void SendNotification(Order_Info _Order , DataTable dt) { string MessageBody = "Edited By : <b>" + Session["User"].ToString().ToUpper() + "</b><br><br>" + DateTime.UtcNow.AddHours(5) + "<br><h3>Before Edit</h3>"; string tableStart = "<table style=\" width:100%;border-collapse: collapse;\">";//border: 1px solid #ddd; string tableEnd = "</table>"; string MessageHeader = "<tr>"; string MessageDataOld = "<tr>"; string MessageDataNew = "<tr>"; for (int i = 1; i < dt.Columns.Count - 1; i++) { if (dt.Columns[i].ColumnName != "No_Order_Rem") { MessageHeader += "<th align=\"left\" style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;height: 30px;\">" + dt.Columns[i].ColumnName + "</th>"; string Data = ""; if (dt.Columns[i].ColumnName == "Order") { DataTable dt2 = Order_DA.Get_Order_By_Id(int.Parse( dt.Rows[0][i].ToString())); Data = dt2.Rows[0]["Order_No"].ToString(); } else if (dt.Columns[i].ColumnName == "Style") { DataTable dt2 = Style_DA.Get_Style_By_Id(int.Parse(dt.Rows[0][i].ToString())); Data = dt2.Rows[0]["Name"].ToString(); } else if (dt.Columns[i].ColumnName == "Size") { DataTable dt2 = Style_DA.Get_Size_By_Id(int.Parse(dt.Rows[0][i].ToString())); Data = dt2.Rows[0]["No"].ToString(); } else if (dt.Columns[i].ColumnName == "Date") { Data = Convert.ToDateTime( dt.Rows[0][i].ToString()).ToString("MM/dd/yyyy"); } else { Data = dt.Rows[0][i].ToString(); } MessageDataOld += "<td style=\"border-top: 1px solid #ddd;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + Data + "</td>"; } } MessageDataOld += "</tr>"; MessageHeader += "</tr>"; MessageDataNew += "<td style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + ((DataTable)Order_DA.Get_Order_By_Id(_Order.Order)).Rows[0]["Order_No"].ToString() + "</td>"; MessageDataNew += "<td style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + _Order.No_Order + "</td>"; MessageDataNew += "<td style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + ((DataTable)Style_DA.Get_Style_By_Id(_Order.Style)).Rows[0]["Name"].ToString() + "</td>"; MessageDataNew += "<td style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + ((DataTable)Style_DA.Get_Size_By_Id(_Order.Size)).Rows[0]["No"].ToString() + "</td>"; MessageDataNew += "<td style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + _Order.DateString + "</td>"; MessageDataNew += "<td style=\"border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-family:Courier New;height: 50px;\">" + _Order.Description + "</td>"; MessageDataNew += "</tr>"; MessageBody += tableStart + MessageDataOld + MessageHeader + MessageDataNew + tableEnd + "<h3>After Edit</h3>"; sendMail.sendEmailMessage(ConfigurationManager.AppSettings["From"], ConfigurationManager.AppSettings["To"], ConfigurationManager.AppSettings["Password"], "Order Info Edit", MessageBody); }
public string Update(int Id, int Order, int Style, int Size, int No_Order, string Date, string Description) { Order_Info _Order = new Order_Info(); _Order.Id = Id; _Order.Order = Order; _Order.Style = Style; _Order.Size = Size; _Order.No_Order = No_Order; _Order.DateString = Date; _Order.Description = Description; DataTable dt = Order_Info_DA.Get_OrderInfo_By_Id(_Order.Id); string message = Order_Info_DA.UpdateOrderInfo(_Order); if (message != "1" && Session["User"].ToString().ToUpper() != ("Mustafa Piracha").ToUpper()) { SendNotification(_Order,dt); } return message; }
public Order_Info Get_OrderInfo_By_Id(int Id) { Order_Info _Order = new Order_Info(); DataTable dt = Order_Info_DA.Get_OrderInfo_By_Id(Id); foreach (DataRow row in dt.Rows) { int order = int.Parse(row["Order"].ToString()); int style = int.Parse(row["Style"].ToString()); int size = int.Parse(row["Size"].ToString()); int no_Order = int.Parse(row["No_Order"].ToString()); DateTime Date = Convert.ToDateTime(row["Date"].ToString()); string Description = row["Description"].ToString(); _Order.Id = Id; _Order.Order = order; _Order.Description = Description; _Order.Style = style; _Order.Size = size; _Order.No_Order = no_Order; _Order.DateString = Date.ToString("MM/dd/yyyy"); } return _Order; }
public static string UpdateOrderInfo(Order_Info _order_info) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_UpdateOrderinfo"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Id"; param.Value = _order_info.Id; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Order"; param.Value = _order_info.Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@No_Order"; param.Value = _order_info.No_Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Style"; param.Value = _order_info.Style; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Size"; param.Value = _order_info.Size; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Date"; param.Value = _order_info.DateString; param.DbType = DbType.Date; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Description"; param.Value = _order_info.Description; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); string Return = command.Parameters["@Return"].Value.ToString(); return Return; }
public static string InsertOrder_Info(Order_Info _Order_Info) { DbCommand command = Catalog_Access.CreateCommand(); command.CommandText = "sp_insertOrder_Info"; DbParameter param; param = command.CreateParameter(); param.ParameterName = "@Order"; param.Value = _Order_Info.Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Size"; param.Value = _Order_Info.Size; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Style"; param.Value = _Order_Info.Style; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@No_Order"; param.Value = _Order_Info.No_Order; param.DbType = DbType.Int32; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Date"; param.Value = _Order_Info.DateString; param.DbType = DbType.Date; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Description"; param.Value = _Order_Info.Description; param.DbType = DbType.String; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@IsDeleted"; param.Value = _Order_Info.IsDeleted; param.DbType = DbType.Boolean; command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@Return"; param.DbType = DbType.String; param.Size = 2; param.Direction = ParameterDirection.Output; command.Parameters.Add(param); Catalog_Access.ExecuteNonQuery(command); string Return = command.Parameters["@Return"].Value.ToString(); if (Return == Constants.SP_ALREADY_EXIST) { return Constants.ALREADY_EXIST; } else { return Constants.SUCESS_INSERT; } }