private void appVideoAcceptHandler() { if (OnServerLog != null) { OnServerLog("\n<< VideoAccept数据处理 >>"); } int neckLen = (int)(Encoding.UTF8.GetChars(data, 1, 1)[0]); String neckname = Encoding.UTF8.GetString(data, 2, neckLen); int sendPort = (int)(Encoding.UTF8.GetChars(data, 2 + neckLen, 4)[0]); int spLen = Encoding.UTF8.GetByteCount(((char)sendPort).ToString()); int recvPort = (int)(Encoding.UTF8.GetChars(data, 2 + neckLen + spLen, 4)[0]); ChaitMirror targetClient = ChaitServer.Instance.Clients[neckname]; String ip = ClientIP.Split(new char[] { ':' })[0]; String msgStr = System.Convert.ToChar(CProtocol.VideoAccept).ToString() + ((char)Encoding.UTF8.GetBytes(ClientNeck).Length).ToString() + ClientNeck + ((char)Encoding.UTF8.GetBytes(ip).Length).ToString() + ip + ((char)sendPort).ToString() + ((char)recvPort).ToString(); targetClient.transSendMsg(msgStr); if (OnServerLog != null) { OnServerLog(String.Format("{0}接受了{1}的视频聊天请求", ClientNeck, neckname)); } if (OnServerLog != null) { OnServerLog("\n"); } }
public Client(TcpClient client, string IP) { ClientIP = IPAddress.Parse(IP); ClientTCP = client; int timeout = 10000; ClientTCP.ReceiveTimeout = timeout; ClientTCP.SendTimeout = timeout; ClientStream = client.GetStream(); Sender = new DataSend(this); Reader = new DataRead(this); if (CommonDatas.NetworkSpareLevel > 100) { Checking = false; } else { Checking = true; } LifeCheckerThread = new Thread(CheckLife) { Name = $"checker_{ClientIP.ToString()}", IsBackground = true, }; LifeCheckerThread.Start(); }
private void InitSocket() { try { tbxLocalIpAddress.Text = Regex.Replace(tbxLocalIpAddress.Text, @"[^0-9].[^0-9].[^0-9].[^0-9]", ""); tbxPort.Text = Regex.Replace(tbxPort.Text, @"[^0-9]", ""); if (tbxLocalIpAddress.Text == "" || tbxPort.Text == "") { MessageBox.Show("Local IP Address 또는 Port 번호가 올바르지 않습니다."); throw new Exception(); } TcpListner = new TcpListener(IPAddress.Parse(tbxLocalIpAddress.Text.Trim()), Int32.Parse(tbxPort.Text)); TcpClient = default(TcpClient); TcpListner.Start(); DisplayText(">> server Started"); while (true) { try { TcpClient = TcpListner.AcceptTcpClient(); NetworkStream stream = TcpClient.GetStream(); byte[] buffer = new byte[1024]; int bytes = stream.Read(buffer, 0, buffer.Length); string channel = Encoding.Unicode.GetString(buffer, 0, bytes); channel = channel.Split('$')[0]; this.Invoke(new DeligateGetClientIP(GetClientIP), channel); ClientList.Add(TcpClient, channel); IpPoint = (IPEndPoint)TcpClient.Client.RemoteEndPoint; ClientIP = IpPoint.Address + ":" + IpPoint.Port; ClientInfoList.Add(ClientIP.ToString()); SendMessageAll(ClientIP + "/ 님이 연결되었습니다.", channel, false); HandleClient handle = new HandleClient(); handle.OnReceived += new HandleClient.MessageDisplayHandler(OnReceived); handle.OnDisconnected += new HandleClient.DisconnectedHandler(HandlerClientsOnDisconnected); handle.StartClient(TcpClient, ClientList); } catch { throw new SocketException(); } } } catch (SocketException ex) { this.Invoke(new DeligateDisconnect(Disconnect)); } catch (Exception ex) { } finally { this.Invoke(new DeligateButtonChange(ButtonStatusChange)); } }
void SmoothStreamingSourceChanged(string url) { Uri currentStreamUri = new Uri(url, UriKind.Absolute); IsEdgeServerComplete = false; EdgeServer = EdgeServerDataClient.IpNA; // clear the current edge server ClientIP = EdgeServerDataClient.IpNA; if (Configuration.EdgeServerRuleCollection != null) { EdgeServerRules addressRules = Configuration.EdgeServerRuleCollection.FirstOrDefault(ai => ai.Domain != null && currentStreamUri.Host.EndsWith(ai.Domain, StringComparison.OrdinalIgnoreCase)); // fallback on the address rules without a domain if (addressRules == null) { addressRules = Configuration.EdgeServerRuleCollection.FirstOrDefault(ai => ai.Domain == null); } try { if (addressRules != null) { EdgeServerDataClient edgeServerDataClient = new EdgeServerDataClient(); edgeServerDataClient.GetEdgeServerCompleted += (s, e) => { // warning: this can come back after we've shut down, checking for the mediaelement is a good way to ensure we're still supposed to be tracking if (mediaElement != null) { if (e.Result != null) { EdgeServer = e.Result.EdgeServer; ClientIP = e.Result.ClientIP; } FinishSettingEdgeServer(); SmoothStreamingEvent entry = new SmoothStreamingEvent(); entry.EventType = EventType.AddressInfo; entry.Data1 = ClientIP.ToString(); entry.Data2 = EdgeServer; Enqueue(entry); } }; edgeServerDataClient.GetEdgeServerAsync(addressRules, currentStreamUri); } else { FinishSettingEdgeServer(); } } catch { FinishSettingEdgeServer(); } } else { FinishSettingEdgeServer(); } }
public void CmdSendIPToServer(string networkID, string ipAddress) { ClientIP c = new ClientIP(networkID, ipAddress); if (!clientIPList.Contains(c)) { clientIPList.Add(c); RpcSetID(c); } }
private void CheckPermission(PagedList <PostDto> posts) { var location = ClientIP.GetIPLocation() + "|" + Request.Headers[HeaderNames.UserAgent]; posts.Data.RemoveAll(p => p.LimitMode switch { PostLimitMode.AllowRegion => !location.Contains(p.Regions.Split(',', StringSplitOptions.RemoveEmptyEntries)) && !CurrentUser.IsAdmin && !VisitorTokenValid && !Request.IsRobot(), PostLimitMode.ForbidRegion => location.Contains(p.Regions.Split(',', StringSplitOptions.RemoveEmptyEntries)) && !CurrentUser.IsAdmin && !VisitorTokenValid && !Request.IsRobot(), _ => false });
void RpcSetID(ClientIP cl) { // if (!isServer) // { // clientIPList.Add (cl); // } if (!isLocalPlayer) { SetOptitrackID(); } }
internal override PacketWriter GetWriter() { PacketWriter writer = new PacketWriter((ushort)(1 + 103)); writer.Write(PacketID); writer.Write(pattern1); writer.Write(pattern2); writer.Write(pattern3); writer.WriteStringFixed(CharName, 30); writer.Write(unknown0); writer.Write((int)ClientFlags); writer.Write(unknown1); writer.Write(LoginCount); writer.Write((byte)Profession); writer.Skip(15); //unknown2[15]; writer.Write(RaceAndGender.ToByte()); writer.Write(Stats.Strength); writer.Write(Stats.Dexterity); writer.Write(Stats.Intelligence); writer.Write(StartSkills.Length > 0 ? (byte)StartSkills[0].Skill : (byte)0); writer.Write(StartSkills.Length > 0 ? (byte)StartSkills[0].Value : (byte)0); writer.Write(StartSkills.Length > 1 ? (byte)StartSkills[1].Skill : (byte)0); writer.Write(StartSkills.Length > 1 ? (byte)StartSkills[1].Value : (byte)0); writer.Write(StartSkills.Length > 2 ? (byte)StartSkills[2].Skill : (byte)0); writer.Write(StartSkills.Length > 2 ? (byte)StartSkills[2].Value : (byte)0); writer.Write((ushort)SkinColor); writer.Write((ushort)HairStyle); writer.Write((ushort)HairColor); writer.Write((ushort)FacialHairStyle); writer.Write((ushort)FacialHairColor); writer.Write(StartLocationIndex); writer.Write(unknown3); writer.Write(CharSlotNum); byte[] addressbytes = ClientIP.GetAddressBytes(); writer.Write(addressbytes[0]); writer.Write(addressbytes[1]); writer.Write(addressbytes[2]); writer.Write(addressbytes[3]); writer.Write((ushort)ShirtColor); writer.Write((ushort)PantsColor); return(writer); }
protected void btnSave_Click(object sender, EventArgs e) { using (con = new SqlConnection(strcon)) { try { ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); string browser = Request.Browser.Browser.ToString(); string version = Request.Browser.Version.ToString(); string useragent = browser + version; if (ViewState["Present"].ToString() == 1.ToString()) { Update = "Update officers_list set DM_Name=N'" + txtDMName.Text + "',DM_MailId='" + txtDMMail.Text + "',DM_Mobile='0" + txtDMMobile.Text + "',DM_IP_Address='" + GetIp.ToString() + "',DM_Current_DateTime=GETDATE(),DM_User_Agent='" + useragent + "',RM_Mobile='" + txtDMMobile2.Text + "',PanNo='" + txtPanNo.Text + "',TinNo='" + txtTinNo.Text + "' where District_code='" + ddlDist.SelectedValue.ToString() + "'"; } else { Update = "Insert Into officers_list (DM_Name,DM_MailId,DM_Mobile,DM_IP_Address,DM_Current_DateTime,DM_User_Agent,District_code,District,RM_Mobile,PanNo,TinNo) values(N'" + txtDMName.Text + "','" + txtDMMail.Text + "','0" + txtDMMobile.Text + "','" + GetIp.ToString() + "',GETDATE(),'" + useragent + "',N'" + ddlDist.SelectedValue.ToString() + "','" + ddlDist.SelectedItem.ToString() + "','" + txtDMMobile2.Text + "','" + txtPanNo.Text + "','" + txtTinNo.Text + "')"; } con.Open(); cmd = new SqlCommand(Update, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Save Successfully...'); </script> "); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } }
protected void btnSave_Click(object sender, EventArgs e) { using (con = new SqlConnection(strcon)) { try { ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); if (ViewState["Present"].ToString() == 1.ToString()) { Update = string.Format("Update officers_list set DMO_Name=N'{0}',DMO_MailId='{1}',DMO_Mobile={2},DMO_IP='{3}',DMO_CreatedDate={4} where District_code='" + ddlDist.SelectedValue.ToString() + "' ", txtDMName.Text, txtDMMail.Text, "0" + txtDMMobile.Text, GetIp.ToString(), "GETDATE()"); } else { Update = string.Format("Insert Into officers_list (DMO_Name,DMO_MailId,DMO_Mobile,DMO_IP,DMO_CreatedDate,District_code,District) values(N'{0}','{1}',{2},'{3}',{4},'{5}','{6}',N'{7}')", txtDMName.Text, txtDMMail.Text, "0" + txtDMMobile.Text, GetIp.ToString(), "GETDATE()", ddlDist.SelectedValue.ToString(), ddlDist.SelectedItem.ToString()); } con.Open(); cmd = new SqlCommand(Update, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Save Successfully...'); </script> "); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } }
private void SetMetaData(Command c) { switch (c.CommandType) { case (type.ClientLogin): c.Meta = ClientIP.ToString() + ":" + netName; break; case (type.PCLockTimer): case (type.PCLogOFFTimer): case (type.PCRestartTimer): case (type.PCShutDownTimer): case (type.UserExitTimer): c.Meta = "60000"; break; default: c.Meta = "\n"; break; } }
public async Task <IActionResult> Redirect(int id) { var ad = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("推广链接不存在"); if (!Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get <string>("ads" + id))) { HttpContext.Session.Set("ads" + id, id.ToString()); ad.ClickRecords.Add(new AdvertisementClickRecord() { IP = ClientIP, Location = ClientIP.GetIPLocation(), Referer = Request.Headers[HeaderNames.Referer].ToString(), Time = DateTime.Now }); await AdsService.SaveChangesAsync(); var start = DateTime.Today.AddMonths(-6); await ClickRecordService.GetQuery(a => a.Time < start).DeleteFromQueryAsync(); } return(Redirect(ad.Url)); }
public async Task <ActionResult> RandomGo() { var ad = AdsService.GetByWeightedPrice((AdvertiseType) new Random().Next(1, 4), Request.Location()); if (!Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get <string>("ads" + ad.Id))) { HttpContext.Session.Set("ads" + ad.Id, ad.Id.ToString()); ad.ClickRecords.Add(new AdvertisementClickRecord() { IP = ClientIP, Location = ClientIP.GetIPLocation(), Referer = Request.Headers[HeaderNames.Referer].ToString(), Time = DateTime.Now }); await AdsService.SaveChangesAsync(); var start = DateTime.Today.AddMonths(-1); await ClickRecordService.GetQuery(a => a.Time < start).DeleteFromQueryAsync(); } return(Redirect(ad.Url)); }
private void connector_DoWork(object sender, DoWorkEventArgs e) { try { client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); client.Connect(endpoint); e.Result = true; netStream = new NetworkStream(client); receiver = new BackgroundWorker(); receiver.WorkerSupportsCancellation = true; receiver.DoWork += new DoWorkEventHandler(StartReceive); receiver.RunWorkerAsync(); //send a notification that this client has connnected Command massMsg = new Command(type.ClientLogin, IPAddress.Broadcast, ClientIP.ToString() + ":" + netName); SendCommand(massMsg); } catch { e.Result = false; } }
private void CheckPermission(Post post) { var location = ClientIP.GetIPLocation(); switch (post.LimitMode) { case PostLimitMode.AllowRegion: if (!location.Contains(post.Regions.Split(',', StringSplitOptions.RemoveEmptyEntries)) && !CurrentUser.IsAdmin && !VisitorTokenValid && !Request.IsRobot()) { throw new NotFoundException("文章未找到"); } break; case PostLimitMode.ForbidRegion: if (location.Contains(post.Regions.Split(',', StringSplitOptions.RemoveEmptyEntries)) && !CurrentUser.IsAdmin && !VisitorTokenValid && !Request.IsRobot()) { throw new NotFoundException("文章未找到"); } break; } }
public void Disconnect() { //már nem küld semmi adatot SendingDatas = false; //a kliens kiszedése a kliens listából ClientMethods.RemoveClient(this); try { //a kapcsolat bezárása ClientTCP.Close(); //a stream bezárása ClientStream.Close(); } catch (Exception) { } Checking = false; DisconnectOperations.SetKilokosOffline(ClientIP.ToString()); }
public override void OnException(ExceptionContext filterContext) { filterContext.ExceptionHandled = true; //表示已经处理 不需要mvc框架处理 var UserData = HttpContext.Current.User as MyFormsPrincipal <UserInfo>; //当前操作用户 UsersExtend curentUser = null; var routeValueDic = filterContext.RouteData.Values; string actionParameterInfo; try { actionParameterInfo = GetActionParametersInfoStr(filterContext); } catch { actionParameterInfo = "参数信息:不能处理参数绑定"; } if (UserData != null) { curentUser = DepositHelper.GetAsync <UsersExtend>(RedisKeyManager.LoginUserInfo(UserData.UserData.Id.ToString())); } //如果是ajax请求则返回json格式数据 否则跳转到错误页面 if (filterContext.HttpContext.Request.IsAjaxRequest()) { JsonResult json = new JsonResult(); json.Data = new ProcessResult() { State = ProcessEnum.Fail, Message = filterContext.Exception.Message }; filterContext.Result = json; } else { filterContext.Result = new RedirectResult("/plug/Error/Error404.html"); } log.Error(ClientIP.GetIp(filterContext.RequestContext.HttpContext.ApplicationInstance.Request), curentUser == null ? "未登陆" : curentUser.LoginName, filterContext.HttpContext.Request.UrlReferrer.ToString(), routeValueDic["action"].ToString(), "mvc全局捕获异常", filterContext.Exception, actionParameterInfo);//写入日志 base.OnException(filterContext); }
public void MakeKeepAlivePacket(out byte[] data, int type, int ran) { if (type == 0) { data = new byte[38]; data[0] = 0xff; Buffer.BlockCopy(md5a, 0, data, 1, 16); Buffer.BlockCopy(tail, 0, data, 20, 16); data[36] = (byte)(ran >> 8); data[37] = (byte)(ran & 0xFFFFFFFF); } else { data = new byte[40]; data[0] = 0x07; data[1] = 0x00; data[2] = 0x28; data[4] = 0x0b; data[5] = (byte)(2 * type - 1); // keepaliveVer data[6] = 0xdc; data[7] = 0x02; data[9] = (byte)(ran >> 8); data[10] = (byte)(ran); Buffer.BlockCopy(flux, 0, data, 16, 4); if (type == 2) { Buffer.BlockCopy(ClientIP.GetAddressBytes(), 0, data, 28, 4); } } #if DEBUG OnLog.Invoke("alive", data, true); #else OnLog.Invoke("alive", "Sending keep-alive-" + type.ToString() + " packet...", false); #endif }
public void WriteTo(Stream writer) { writer.WriteByte((byte)Operation); writer.WriteByte((byte)HardwareType); writer.WriteByte((byte)HardwareAddressLength); writer.WriteByte((byte)Hops); BinaryHelper.Write(writer, TransactionId); BinaryHelper.Write(writer, SecondElapsed); if (Broadcast) { BinaryHelper.Write(writer, 0x8000); } else { BinaryHelper.Write(writer, (uint)0); } BinaryHelper.Write(writer, ClientIP.GetAddressBytes()); BinaryHelper.Write(writer, Your.GetAddressBytes()); BinaryHelper.Write(writer, NextIP.GetAddressBytes()); BinaryHelper.Write(writer, RelayAgentIP.GetAddressBytes()); BinaryHelper.Write(writer, ClientHardwareAddress); BinaryHelper.Write(writer, ServerHostName); BinaryHelper.Write(writer, BootFileName); if (IsDhcpMessage) //Magic cookie { BinaryHelper.Write(writer, new byte[] { 63, 82, 53, 63 }); } if (Options != null && Options.Count > 0) { foreach (Option option in Options) { writer.WriteByte((byte)option.Type); option.WriteTo(writer); } } }
// Use this for initialization void Start() { if (!NetworkServer.active) { ipAddress = Network.player.ipAddress; SetOptitrackID(); } if (isLocalPlayer) { SendIP(); ClientIP c = new ClientIP(netId.ToString(), Network.player.ipAddress); // if (isServer) // { // clientIPList.Add (c); // } if (!isServer) { CmdSendIPToServer(c.networkID, c.ipAddress); } SetOptitrackID(); } }
protected void btnDelete_Click(object sender, EventArgs e) { if (ddlPageNo.SelectedIndex <= 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('कृपया Page Number चुने |'); </script> "); return; } else if (txtIssuedQty.Text == "" || txtTCNo.Text == "") { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Issued Qty Or Truck Number Is Not Allow Blank'); </script> "); return; } else { if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { string instr = ""; ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); con.Open(); if (hdfIsRecd.Value == "Y") { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('प्राप्तकर्ता जिले द्वारा कमोडिटी प्राप्त कर ली गयी है, इसलिए आप इस डिलेवरी चालान को डिलीट नहीं कर सकते |'); </script> "); return; } else { instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " + "Update TruckChallan_Book set Rem_Page=Rem_Page+1 where Book_No='" + ddlBookNo.SelectedItem.ToString() + "' and District='" + hdfFrmDist.Value + "';"; instr += "Update RackReceived set Rem_Qty=(Rem_Qty+'" + txtIssuedQty.Text + "'),Rem_Bags=(Rem_Bags+'" + hdfIssued_Bags.Value + "') where Consinment_No='" + txtConsNo.Text + "';"; if (hdfRMO.Value != "0") { instr += "Update RecAgainst_StateMovementOrder set IssuedQty=(IssuedQty+ " + txtIssuedQty.Text + ") where RMO='" + hdfRMO.Value + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and Godown='" + hdfToGodown.Value + "' and ModeofDispatch='13' ; "; } instr += "Insert Into TO_AgainstHO_MO_Trans_Log(MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,Transporter_ID,FrmDist,ToDist,Commodity,Quantity,CropYear,ReachDate,MODate,TOEndDate,ModeofDispatch,IsIssued,CreatedDate,IP,Issue_Center,Branch,Godown,RequiredQuantity,RemQty,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,Month,Year,IsSend,State_Id,OperatorID,Scheme_Id,DispatchID,STrans_ID,To_MultiDist,SubSMO,ModeofDist,GETDATE(),'" + GetIp + "','U' From TO_AgainstHO_MO where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='13'; "; instr += "Update TO_AgainstHO_MO Set RemQty=(RemQty+" + txtIssuedQty.Text + ") where STO_No='" + hdfSTO_No.Value + "' and MoveOrdernum='" + txtMONo.Text + "' and ModeofDispatch='13'; "; instr += "Insert Into DeliveryChallan_MO_Trans_Logs (MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,DeletedDate,DeletedIP,Operation) select MoveOrdernum,SMO,TO_No,STO_No,DC_No,Transporter_ID,FrmDist,ToDist,Commodity,CropYear,TOEndDate,ModeofDispatch,IsReceived,DC_MO,CreatedDate,IP,OperatorID,Issue_Center,Default_Branch,Default_Godown,Change_Branch,Change_Godown,Issued_Qty,Issued_Date,Issued_Bags,Bags_Type,Truck_No,Stock_Issued_From,FrmRailHaid,ToRailHaid,Rack_No,Rack_DispDate,Trans_ID,STrans_ID,Recd_Qty,Recd_Bags,Recd_Date,RecIC,RecBranch,RecGodown,RSDRecd_Qty,RSDRecd_Bags,RSDRecd_Date,RSDCreatedDate,RRDRecd_Qty,RRDRecd_Bags,RRDRecd_Date,RRDCreated,Distance,Consinment_No,Book_No,Page_No,SubSMO,RMO,GETDATE(),'" + GetIp + "','D' From DeliveryChallan_MO where DC_MO='" + ddlPageNo.SelectedValue.ToString() + "' and SMO='" + hdfSMO.Value + "' and STO_No='" + hdfSTO_No.Value + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='13' and Issue_Center='0000' and Truck_No='" + txtTCNo.Text + "' and Book_No='" + ddlBookNo.SelectedItem.ToString() + "' and Page_No='" + ddlPageNo.SelectedItem.ToString() + "' and Consinment_No='" + txtConsNo.Text + "' and IsReceived='N'; "; instr += "Delete From DeliveryChallan_MO where DC_MO='" + ddlPageNo.SelectedValue.ToString() + "' and SMO='" + hdfSMO.Value + "' and STO_No='" + hdfSTO_No.Value + "' and FrmDist='" + hdfFrmDist.Value + "' and ToDist='" + hdfToDist.Value + "' and ModeofDispatch='13' and Issue_Center='0000' and Truck_No='" + txtTCNo.Text + "' and Book_No='" + ddlBookNo.SelectedItem.ToString() + "' and Page_No='" + ddlPageNo.SelectedItem.ToString() + "' and Consinment_No='" + txtConsNo.Text + "' and IsReceived='N'; "; instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); END CATCH;"; } cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnDelete.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('डिलेवरी चालान सफलता पूर्वक डिलीट हो चूका है|'); </script> "); txtIssuedQty.Text = ""; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } }
protected void btnReject_Click(object sender, EventArgs e) { if (ddlMobileNo.SelectedIndex <= 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select Mobile Number For OTP'); </script> "); return; } else { if (txtDispMode.Text != "" && txtCommodity.Text != "") { ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { con.Open(); string instr = ""; instr = "Update StateMovementOrder Set IsAccepted='N', AcceptedIP='" + GetIp + "',AcceptedDate=GETDATE(),Accepted_EmpID='" + hdfEmpID.Value + "',Accepted_MobileNo='" + hdfMobileNo.Value + "',Accepted_OTP='" + hdfOTP.Value + "' where MoveOrdernum='" + ddlMvmtNo.SelectedItem.ToString() + "'"; cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnAccept.Enabled = btnReject.Enabled = ddlMvmtNo.Enabled = false; ChkOTP.Disabled = true; btnPrint.Enabled = true; Session["MovmtOrderNo"] = ddlMvmtNo.SelectedItem.ToString(); Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Movement Order Is Rejected'); </script> "); txtDispMode.Text = txtCommodity.Text = ""; Session["Acpt/Rjct"] = "Reject"; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } txtDispMode.Text = txtCommodity.Text = ""; } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } } }
protected void btnSave_Click(object sender, EventArgs e) { if (ddl_distancefrom.SelectedIndex == 0) { Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select Distance from...');</script>"); return; } if (ddl_relatedDistrict.SelectedIndex == 0) { btnSave.Enabled = true; Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select District Name.....');</script>"); return; } if (ddl_distancefrom.SelectedValue.ToString() != "12") { if (ddlissuecenter.SelectedIndex == 0) { btnSave.Enabled = true; Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select Issue Center Name......');</script>"); return; } } if (ddl_distancefrom.SelectedValue.ToString() != "12") { if (ddl_Godown.SelectedIndex == 0) { btnSave.Enabled = true; Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Select Godown......');</script>"); return; } } if (txt_distance.Text == "" || txt_distance.Text == "0") { btnSave.Enabled = true; Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Enter distance......');</script>"); return; } string pc_id = ""; if (ddl_distancefrom.SelectedValue.ToString() != "12") { pc_id = ddl_PCeneter.SelectedValue.ToString(); } else { pc_id = ddl_relatedDistrict.SelectedValue.ToString(); } con.Close(); string dist = distid; string Issue = ddlissuecenter.SelectedValue; ClientIP objClientIP = new ClientIP(); string IP = objClientIP.GETIP(); string user = Session["OperatorIDDM"].ToString(); if (ddl_distancefrom.SelectedValue == "11") //From Paddy Mill To Godown { if (ddl_PCeneter.SelectedIndex == 0) { Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Please Select Mill Name...');</script>"); return; } try { if (con.State == ConnectionState.Closed) { con.Open(); } string Check = "Select * From Distance_Master_Godown where DistrictId='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "' and Distance_For='" + ddl_distancefrom.SelectedValue.ToString() + "'"; SqlDataAdapter da = new SqlDataAdapter(Check, con); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count == 0) { try { string insqry = "Insert into Distance_Master_Godown (DistrictId ,PCCodeOrRailheadcode ,IssueCenter ,Godown_id,distance,Distance_For,CreatedDate,IP_Address) values ('" + ddl_relatedDistrict.SelectedValue.ToString() + "','" + ddl_PCeneter.SelectedValue.ToString() + "','" + ddlissuecenter.SelectedValue.ToString() + "', '" + ddl_Godown.SelectedValue.ToString() + "','" + txt_distance.Text + "','" + ddl_distancefrom.SelectedValue.ToString() + "',getdate(),'" + IP + "')"; SqlCommand cmdins = new SqlCommand(insqry, con); int count = cmdins.ExecuteNonQuery(); if (count > 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Sucessfully....'); </script> "); btnSave.Enabled = false; } } catch (Exception ex) { btnSave.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } else { try { string insqry = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where DistrictId='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "' and Distance_For='" + ddl_distancefrom.SelectedValue.ToString() + "'"; SqlCommand cmdins = new SqlCommand(insqry, con); int count = cmdins.ExecuteNonQuery(); if (count > 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Updated Sucessfully....'); </script> "); //btnSave.Enabled = false; } } catch (Exception ex) { //btnSave.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } catch (Exception ex) { //btnSave.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } else { if (btnSave.Text == "Save") { string mystr = ""; if (ddl_distancefrom.SelectedValue.ToString() == "PC") { mystr = "SELECT *FROM [Distance_Master_Godown] where [PCCodeOrRailheadcode]='" + ddl_PCeneter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "' "; } else if (ddl_distancefrom.SelectedValue.ToString() == "12") { mystr = "SELECT *FROM [Distance_Master_Godown] where [DistrictId]='" + Session["dist_id"].ToString() + "' and PCCodeOrRailheadcode='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and transport_mode='" + ddl_transportmode.SelectedValue.ToString() + "' "; } else { mystr = "SELECT *FROM [Distance_Master_Godown] where [PCCodeOrRailheadcode]='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "' "; } con.Open(); SqlCommand cmdwhr = new SqlCommand(mystr, con); SqlDataReader sqldr = cmdwhr.ExecuteReader(); sqldr.Read(); if (sqldr.HasRows) { Page.RegisterClientScriptBlock("asdsad", "<script language=javascript > alert('Distance already save kindly Update it from the list......');</script>"); return; } con.Close(); // string distance = gr.Cells[3].Text; string insqry = "Insert into Distance_Master_Godown (transport_mode,DistrictId ,PCCodeOrRailheadcode ,IssueCenter ,Godown_id,distance,Distance_For,CreatedDate,IP_Address) values ('" + ddl_transportmode.SelectedValue.ToString() + "','" + Session["dist_id"].ToString() + "','" + pc_id + "','" + ddlissuecenter.SelectedValue.ToString() + "', '" + ddl_Godown.SelectedValue.ToString() + "','" + txt_distance.Text + "','" + ddl_distancefrom.SelectedValue.ToString() + "',getdate(),'" + IP + "')"; SqlCommand cmdins = new SqlCommand(insqry, con); //string upsqry = "Update dbo.TO_for_Purchesecenter set distance_pc_godown='" + txt_distance.Text + "' where pc_id='" + ddl_PCeneter.SelectedValue.ToString() + "'and Godownid='" + ddl_Godown.SelectedValue.ToString() + "'"; //SqlCommand cmdups = new SqlCommand(upsqry, con); if (con.State == ConnectionState.Closed) { con.Open(); } try { int x = cmdins.ExecuteNonQuery(); //int z = cmdups.ExecuteNonQuery(); Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Sucessfuly...'); </script> "); //btnSave.Enabled = false; //Response.Redirect("~/District/PCenterto_godown_distance.aspx"); } catch { btnSave.Enabled = true; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Problem Arise, pls try again...'); </script> "); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } } else { try { string insertdistance = ""; if (ddl_distancefrom.SelectedValue.ToString() == "2") { insertdistance = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and IssueCenter='" + ddlissuecenter.SelectedValue.ToString() + "'"; } else if (ddl_distancefrom.SelectedValue.ToString() == "12") { insertdistance = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where PCCodeOrRailheadcode='" + ddl_relatedDistrict.SelectedValue.ToString() + "' and DistrictId='" + Session["dist_id"].ToString() + "' and transport_mode='" + ddl_transportmode.SelectedValue.ToString() + "'"; } else { insertdistance = "Update Distance_Master_Godown set distance= '" + txt_distance.Text + "' where PCCodeOrRailheadcode='" + ddl_PCeneter.SelectedValue.ToString() + "' and Godown_id='" + ddl_Godown.SelectedValue.ToString() + "'"; } SqlCommand cmdins = new SqlCommand(insertdistance, con); if (con.State == ConnectionState.Closed) { con.Open(); } int x = cmdins.ExecuteNonQuery(); con.Close(); string qry = "Update dbo.TO_for_Purchesecenter set distance_pc_godown='" + txt_distance.Text + "' where pc_id='" + ddl_PCeneter.SelectedValue.ToString() + "'and Godownid='" + ddl_Godown.SelectedValue.ToString() + "' "; SqlCommand cmsd = new SqlCommand(qry, con); con.Open(); int y = cmsd.ExecuteNonQuery(); try { //con.Open(); cmsd.ExecuteNonQuery(); Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Updated successfully...'); </script> "); btnSave.Enabled = false; } catch (Exception ex) { //Label1.Visible = true; //Label1.Text = ex.Message; } finally { con.Close(); //ComObj.CloseConnection(); } fillgrid(); //Panel1.Visible = false; } catch { } } } }
protected void btnRecptSubmit_Click(object sender, EventArgs e) { if (txtCommodity.Text != "" && txtCropYear.Text != "") { double SendQty = 0, RecQty = 0; int SendBags = 0, RecBags = 0; SendQty = double.Parse(txtSendingQty.Text); RecQty = double.Parse(txtRecdQty.Text); SendBags = int.Parse(txtSendingBags.Text); RecBags = int.Parse(txtRecdBags.Text); if (SendQty < RecQty) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Receiving Qty की मात्रा, Sending Qty की मात्रा से ज्यादा है,कृपया Receiving Qty की मात्रा कम करें|'); </script> "); return; } else if (SendBags < RecBags) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Receiving Bags की मात्रा, Sending Bags की मात्रा से ज्यादा है,कृपया Receiving Bags की मात्रा कम करें|'); </script> "); return; } else { if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { con.Open(); string Update = ""; districtid = Session["dist_id"].ToString(); ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); ConvertServerDate ServerDate = new ConvertServerDate(); string RecDate = ServerDate.getDate_MDY(txtRecdDate.Text); string SendDate = ServerDate.getDate_MDY(txtSendingDate.Text); Update = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION " + "Update QtyReceived_RackDispatchPoint set IsReceived='Y' where Racknumber='" + ddlRackNo.SelectedItem.ToString() + "' and sendingDist='" + hdfSendDist.Value + "' and TruckChallan='" + ddlChallanNo.SelectedItem.ToString() + "' and RecDist='" + districtid + "';"; Update += "Insert into Rack_ReceivedPoint(Rack_No,DC_MO,MoveOrdernum,SMO,FrmDist,RecDist,Commodity,CropYear,Send_Qty,Recd_Qty,Rem_Qty,Send_Bags,Recd_Bags,Rem_Bags,Send_Date,Recd_Date,CreatedDate,IP) values('" + ddlRackNo.SelectedItem.ToString() + "','" + ddlChallanNo.SelectedItem.ToString() + "','" + txtMoNO.Text + "','" + hdfSubMO.Value + "','" + hdfSendDist.Value + "','" + districtid + "','" + hdfComdty.Value + "','" + txtCropYear.Text + "','" + SendQty + "','" + RecQty + "','" + RecQty + "','" + SendBags + "','" + RecBags + "','" + RecBags + "','" + SendDate + "','" + RecDate + "',GETDATE(),'" + GetIp + "');"; Update += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); END CATCH;"; cmd = new SqlCommand(Update, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Data Saved Sucessfully ....'); </script> "); btnRecptSubmit.Enabled = false; txtCommodity.Text = txtCropYear.Text = ""; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } } else { Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Alloted All Quantity'); </script> "); } }
public byte[] MakeLoginPacket(byte[] salt, out byte[] data, out int len) { int pwlen = Password.Length; byte[] mac = MAC.GetAddressBytes(); byte[] md5_src; data = new byte[400]; int i = 0; // Begin data[i++] = 0x03; data[i++] = 0x01; data[i++] = 0x00; data[i++] = (byte)(Username.Length + 20); // MD5 A md5_src = new byte[6 + pwlen]; md5_src[0] = 3; md5_src[1] = 1; Buffer.BlockCopy(salt, 0, md5_src, 2, 4); Buffer.BlockCopy(Encoding.Default.GetBytes(Password), 0, md5_src, 6, pwlen); md5a = MD5(md5_src); Buffer.BlockCopy(md5a, 0, data, 4, 16); i += 16; // Username Buffer.BlockCopy(Encoding.Default.GetBytes(Username), 0, data, i, Username.Length); i += Username.Length > 36 ? Username.Length : 36; // CONTROLCHECKSTATUS ADAPTERNUM data[i++] = 0x20; data[i++] = 0x03; /* (data[4:10].encode('hex'),16)^mac */ Buffer.BlockCopy(md5a, 0, data, i, 6); for (int j = 0; j < 6; j++) { data[i + j] ^= mac[j]; } i += 6; // MD5 B md5_src = new byte[9 + pwlen]; md5_src[0] = 1; Buffer.BlockCopy(Encoding.Default.GetBytes(Password), 0, md5_src, 1, pwlen); Buffer.BlockCopy(salt, 0, md5_src, 1 + pwlen, 4); Buffer.BlockCopy(MD5(md5_src), 0, data, i, 16); i += 16; // Ip number, 1, 2, 3, 4 data[i++] = 0x01; Buffer.BlockCopy(ClientIP.GetAddressBytes(), 0, data, i, 4); i += 16; // MD5 C md5_src = new byte[i + 4]; Buffer.BlockCopy(data, 0, md5_src, 0, i); md5_src[i + 0] = 0x14; md5_src[i + 1] = 0x00; md5_src[i + 2] = 0x07; md5_src[i + 3] = 0x0b; Buffer.BlockCopy(MD5(md5_src), 0, data, i, 8); i += 8; // IPDOG(0x01) 0x00*4 data[i++] = 0x01; i += 4; // Host Name md5_src = Encoding.Default.GetBytes(HostName); Buffer.BlockCopy(md5_src, 0, data, i, md5_src.Length > 32 ? 32 : md5_src.Length); i += 32; // primary dns Buffer.BlockCopy(PrimaryDNS.GetAddressBytes(), 0, data, i, 4); i += 4; // DHCP Server Buffer.BlockCopy(DefaultDHCP.GetAddressBytes(), 0, data, i, 4); i += 4; // secondary dns Buffer.BlockCopy(SecondaryDNS.GetAddressBytes(), 0, data, i, 4); i += 4; // delimeter i += 8; // unknown os_major os_minor OS_build os_unknown data[i++] = 0x94; i += 3; data[i++] = 0x06; i += 3; data[i++] = 0x02; i += 3; data[i++] = 0xf0; data[i++] = 0x23; i += 2; data[i++] = 0x02; i += 3; // unknown string data[i++] = 0x44; data[i++] = 0x72; data[i++] = 0x43; data[i++] = 0x4f; data[i++] = 0x4d; i++; data[i++] = 0xcf; data[i++] = 0x07; data[i++] = 0x68; i += 55; // unknown string 2 data[i++] = 0x33; data[i++] = 0x64; data[i++] = 0x63; data[i++] = 0x37; data[i++] = 0x39; data[i++] = 0x66; data[i++] = 0x35; data[i++] = 0x32; data[i++] = 0x31; data[i++] = 0x32; data[i++] = 0x65; data[i++] = 0x38; data[i++] = 0x31; data[i++] = 0x37; data[i++] = 0x30; data[i++] = 0x61; data[i++] = 0x63; data[i++] = 0x66; data[i++] = 0x61; data[i++] = 0x39; data[i++] = 0x65; data[i++] = 0x63; data[i++] = 0x39; data[i++] = 0x35; data[i++] = 0x66; data[i++] = 0x31; data[i++] = 0x64; data[i++] = 0x37; data[i++] = 0x34; data[i++] = 0x39; data[i++] = 0x31; data[i++] = 0x36; data[i++] = 0x35; data[i++] = 0x34; data[i++] = 0x32; data[i++] = 0x62; data[i++] = 0x65; data[i++] = 0x37; data[i++] = 0x62; data[i++] = 0x31; i += 24; // auth version data[i++] = 0x68; data[i++] = 0x00; data[i++] = 0x00; data[i++] = (byte)(pwlen); // ror password for (int k = 0, x; k < pwlen; k++) { x = md5a[k] ^ Password[k]; data[i++] = (byte)(((x << 3) & 0xFF) + (x >> 5)); } data[i++] = 0x02; data[i++] = 0x0c; // checksum point int check_point = i; data[i++] = 0x01; data[i++] = 0x26; data[i++] = 0x07; data[i++] = 0x11; // 0x00 0x00 mac i += 2; Buffer.BlockCopy(mac, 0, data, i, 6); i += 6; // checksum ulong sum = 1234; ulong check = 0; for (int k = 0; k < i; k += 4) { check = 0; for (int j = 0; j < 4; j++) { check = (check << 2) + data[k + j]; } sum ^= check; } sum = (1968 * sum) & 0xFFFFFFFF; for (int j = 0; j < 4; j++) { data[check_point + j] = (byte)(sum >> (j * 8) & 0x000000FF); } if (pwlen / 4 != 4) { i += (pwlen / 4); } i += 4; data[i++] = 0x60; data[i++] = 0xa2; i += 28; len = i; #if DEBUG OnLog.Invoke("mkpkt", data, true); #else OnLog.Invoke("login", "Making login packet...", false); #endif return(data); }
protected void btnSubmit_Click(object sender, EventArgs e) { DataTable dt = adddetails(); if (dt.Rows.Count <= 0) { Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Add At least One Godown'); </script> "); return; } else if (ddlGodown.SelectedIndex <= 0) { Page.RegisterClientScriptBlock("mymsg2", "<script language=javascript> alert('Please Select At least One Godown'); </script> "); return; } else { if (hdfYear.Value != "") { ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { con.Open(); string ChechMax = ""; decimal MaxMappingNo = 0; ChechMax = "Select Max(Mapping_No) As MaxMap From PM_DistToGodown Where FrmDistrict='" + ddlFrmDist.SelectedValue.ToString() + "' and ToDistrict='" + ddlToDist.SelectedValue.ToString() + "' "; da = new SqlDataAdapter(ChechMax, con); ds = new DataSet(); da.Fill(ds); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string Data = ""; Data = ds.Tables[0].Rows[0]["MaxMap"].ToString(); if (Data == "") { MaxMappingNo = decimal.Parse(ddlFrmDist.SelectedValue.ToString() + ddlToDist.SelectedValue.ToString() + "100000"); } else { string wid = Data.Substring(Data.Length - 6); Int64 wid_ID_new = Convert.ToInt64(wid); wid_ID_new = wid_ID_new + 1; string combine = wid_ID_new.ToString(); MaxMappingNo = decimal.Parse(ddlFrmDist.SelectedValue.ToString() + ddlToDist.SelectedValue.ToString() + combine); } } if (MaxMappingNo != 0) { string instr = ""; instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION "; if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { if (i == 0) { } else { MaxMappingNo = MaxMappingNo + 1; } instr += "Insert Into PM_DistToGodown(FrmDistrict,ToDistrict,Mapping_No,CropYear,IssueCenter,Branch,Godown_id,CreatedDate,IP_Address) Values('" + ddlFrmDist.SelectedValue.ToString() + "','" + ddlToDist.SelectedValue.ToString() + "','" + MaxMappingNo + "','" + hdfYear.Value + "','" + dt.Rows[i]["ICVal"] + "','" + dt.Rows[i]["BranchVal"] + "','" + dt.Rows[i]["GodownVal"] + "',GETDATE(),'" + GetIp + "');"; } } instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); END CATCH;"; cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnSubmit.Enabled = btnAdd.Enabled = false; ddlFrmDist.Enabled = ddlToDist.Enabled = ddlIssueCentre.Enabled = ddlBranch.Enabled = ddlGodown.Enabled = false; hdfYear.Value = ""; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully'); </script> "); Session["ICGBQ"] = null; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Changes Not Allow'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Click On New Button'); </script> "); return; } } }
protected void btnRecptSubmit_Click(object sender, EventArgs e) { if (ddlFrmDist.SelectedIndex > 0) { if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { con.Open(); string frmdis = ddlFrmDist.SelectedValue; Int16 commodity = Convert.ToInt16(ddlCommodity.SelectedValue); string mode = ddlComdtyMode.SelectedValue; string year_do = ""; if (ddlCropYear.SelectedIndex == 0) { year_do = System.DateTime.Now.Date.ToString("yy"); year_do = ((int.Parse(year_do)) - 1).ToString(); } else if (ddlCropYear.SelectedIndex == 2) { year_do = System.DateTime.Now.Date.ToString("yy"); year_do = ((int.Parse(year_do)) + 1).ToString(); } else { year_do = System.DateTime.Now.Date.ToString("yy"); } string month = System.DateTime.Now.Date.ToString("MM"); string CurrentYear = System.DateTime.Now.Date.ToString("yy"); string selectmax = "select max(cast(MoveOrdernum as bigint)) as MoveOrdernum from StateMovementOrder where FrmDist='" + frmdis + "' and CropYear='" + ddlCropYear.SelectedValue.ToString() + "'"; cmd = new SqlCommand(selectmax, con); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); string whr_ID = ds.Tables[0].Rows[0]["MoveOrdernum"].ToString(); if (whr_ID == "") { whr_ID = CurrentYear + year_do + month + frmdis + "100"; } else { string wid = whr_ID.Substring(whr_ID.Length - 4); Int64 wid_ID_new = Convert.ToInt64(wid); wid_ID_new = wid_ID_new + 1; string combine = wid_ID_new.ToString(); whr_ID = CurrentYear + year_do + month + frmdis + combine; } ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); string browser = Request.Browser.Browser.ToString(); string version = Request.Browser.Version.ToString(); string useragent = browser + version; ConvertServerDate ServerDate = new ConvertServerDate(); string ConvertEndDate = ServerDate.getDate_MDY(txtDate.Text); DateTime EndDate = DateTime.Parse(ConvertEndDate); string smsEndDate = EndDate.ToString("dd-MMM-yyyy"); string instr = "", smsToDist = "", modeofDist = ""; if (mode == "13") { if (rdbSelf.Checked) { modeofDist = "Self"; } else if (rdbOther.Checked) { modeofDist = "Other"; } else { modeofDist = "Both"; } } DataTable dt = adddetails(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { ConvertMtToQtls = 0; string SMO = whr_ID + (i + 1); if (commodity == 25) { ConvertMtToQtls = ((double.Parse(dt.Rows[i]["quantity"].ToString()))); } else { ConvertMtToQtls = ((double.Parse(dt.Rows[i]["quantity"].ToString())) * 10); } if (mode == "12") //Transfer By Road { instr += "Insert into StateMovementOrder (MoveOrdernum ,FrmDist,Commodity, CropYear,ReachDate,ModeofDispatch,IsIssued,CreatedDate,IP,SMS_todist,SMS_frmDist,ToDist,Quantity,SMO,RecAgainstHO,DispatchAgainstMO,ReceivedAgainstMO,RemQty,IsAccepted ) Values ('" + whr_ID + "','" + frmdis + "','" + commodity + "','" + ddlCropYear.SelectedValue.ToString() + "','" + ConvertEndDate + "','" + mode + "','N',GETDATE(),'" + GetIp + "','N','N','" + dt.Rows[i]["todistval"] + "','" + ConvertMtToQtls + "','" + SMO + "','N','N','N','" + ConvertMtToQtls + "','F');"; } else { if (commodity == 25) { //string strGunnyType = ""; //if (rdbJUTE.Checked) //{ // strGunnyType = "JUTE"; //} //else //{ // strGunnyType = "PP"; //} instr += "Insert into StateMovementOrder (MoveOrdernum ,FrmDist,Commodity, CropYear,ReachDate,ModeofDispatch,IsIssued,CreatedDate,IP,SMS_todist,SMS_frmDist,ToDist,Quantity,SMO,RecAgainstHO,DispatchAgainstMO,ReceivedAgainstMO,RemQty,ModeofDist,IsAccepted,GunnyType) Values ('" + whr_ID + "','" + frmdis + "','" + commodity + "','" + ddlCropYear.SelectedValue.ToString() + "','" + ConvertEndDate + "','" + mode + "','N',GETDATE(),'" + GetIp + "','N','N','" + dt.Rows[i]["todistval"] + "','" + ConvertMtToQtls + "','" + SMO + "','Y','N','N','" + ConvertMtToQtls + "','" + modeofDist + "','F','" + ddlbagstype.SelectedValue.ToString() + "');"; } else { instr += "Insert into StateMovementOrder (MoveOrdernum ,FrmDist,Commodity, CropYear,ReachDate,ModeofDispatch,IsIssued,CreatedDate,IP,SMS_todist,SMS_frmDist,ToDist,Quantity,SMO,RecAgainstHO,DispatchAgainstMO,ReceivedAgainstMO,RemQty,ModeofDist,IsAccepted) Values ('" + whr_ID + "','" + frmdis + "','" + commodity + "','" + ddlCropYear.SelectedValue.ToString() + "','" + ConvertEndDate + "','" + mode + "','N',GETDATE(),'" + GetIp + "','N','N','" + dt.Rows[i]["todistval"] + "','" + ConvertMtToQtls + "','" + SMO + "','Y','N','N','" + ConvertMtToQtls + "','" + modeofDist + "','F');"; } } //Code For SMS //smsToDist += ((smsToDist == "") ? "" : " , ") + "'" + dt.Rows[i]["todisttext"] + "' = '" + dt.Rows[i]["quantity"] + "'"; //smsToDistCode += ((smsToDistCode == "") ? "" : ",") + "'" + dt.Rows[i]["todistval"] + "'"; } } cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnRecptSubmit.Enabled = btnAdd.Enabled = false; btnPrint.Enabled = true; Session["fdjfhxncdfh"] = null; Session["MovmtOrderNo"] = whr_ID; Label2.Text = "Your Movement Order Number Is : " + whr_ID; Label2.Visible = true; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Saved Successfully & Your Movement Order Number Is : " + whr_ID + "'); </script> "); Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); if (mode == "13") { if (modeofDist != "Self") { btnPrint.Enabled = false; LinkbtnSubMO.Visible = true; } } //Code For SMS //cmd1 = new SqlCommand("Select GETDATE()", con); //DateTime CurrentDate = DateTime.Parse((cmd1.ExecuteScalar()).ToString()); //string smsCurrentDate = CurrentDate.ToString("dd-MMM-yyyy"); //String strSMS = "Movement Order Issued On '" + smsCurrentDate + "' with MO Number='" + whr_ID + "' For '" + ddlCommodity.SelectedItem.ToString() + "', '" + ddlComdtyMode.SelectedItem.ToString() + "' From '" + ddlFrmDist.SelectedItem.ToString() + "' To (" + smsToDist + ")MT With End Date'" + smsEndDate + "'"; //SMS Message = new SMS(); //smsToDistCode += ",'" + frmdis + "'"; //string FindDistContactNo = "select DM_Mobile,RM_Mobile From officers_list where District_code in (" + smsToDistCode + ")"; //da = new SqlDataAdapter(FindDistContactNo, con); //ds = new DataSet(); //da.Fill(ds); //string CheckDuplicate = ""; //if (ds != null) //{ // if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) // { // for (int i = 0; i < ds.Tables[0].Rows.Count; i++) // { // string checkLength = ds.Tables[0].Rows[i]["DM_Mobile"].ToString(); // string checkLengthRM = ds.Tables[0].Rows[i]["RM_Mobile"].ToString(); // if (checkLength.Length == 10) // { // Message.SendSMS(checkLength, strSMS); // } // if (checkLengthRM.Length == 10) // { // if (checkLength != checkLengthRM) // { // if (checkLengthRM != CheckDuplicate) // { // Message.SendSMS(checkLength, strSMS); // CheckDuplicate = checkLengthRM; // } // } // } // } // } //} } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); ddlFrmDist.SelectedIndex = 0; } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } }
protected void btnDelete_Click(object sender, EventArgs e) { if (ddlDONo.SelectedIndex <= 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select CMR DO Number'); </script> "); return; } else if (hdfAcpt.Value == "Y") { btnDelete.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस DEPOSIT ORDER के विरुद्ध चावल जमा किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> "); return; } else if (hdfReject.Value == "Y") { btnDelete.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस DEPOSIT ORDER के विरुद्ध चावल को रिजेक्ट किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> "); return; } else { if (ddlCropyear.SelectedValue.ToString() != "") { if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); ConvertServerDate ServerDate = new ConvertServerDate(); string ConvertFromDate = ServerDate.getDate_MDY(txtDODate.Text); string ConvertToDate = ServerDate.getDate_MDY(txtDOLastDate.Text); con.Open(); string instr = ""; instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION "; instr += "Insert Into PaddyMilling_DO_Log_2017(DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,DeletedDate,DeletedIP,Operation) select DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,GETDATE(),'" + GetIp + "','U' From PaddyMilling_DO_2017 where Mill_Code='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and CropYear='" + ddlCropyear.SelectedValue.ToString() + "' and DhanLot='" + hdfLotNo.Value + "' and Check_DO='" + hdfDONo.Value + "'; "; instr += "Update PaddyMilling_DO_2017 Set DispatchDhan_IC='N' where Mill_Code='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and CropYear='" + ddlCropyear.SelectedValue.ToString() + "' and DhanLot='" + hdfLotNo.Value + "' and Check_DO='" + hdfDONo.Value + "'; "; instr += "Insert Into CMR_DepositOrder_Log(CMR_DO,CMR_RecdDist,Paddy_AgrmtDist,CropYear,Mill_ID,Agreement_ID,Lot_No,DO_No,IssueCenter,Branch,Godown_id,CMR_DODate,CreatedDate,IP_Address,IsAccepted,IsRejected,DeletedDate,DeletedIP,Operation) Select CMR_DO,CMR_RecdDist,Paddy_AgrmtDist,CropYear,Mill_ID,Agreement_ID,Lot_No,DO_No,IssueCenter,Branch,Godown_id,CMR_DODate,CreatedDate,IP_Address,IsAccepted,IsRejected,GETDATE(),'" + GetIp + "','D' From CMR_DepositOrder where CMR_DO='" + ddlDONo.SelectedItem.ToString() + "' ; "; instr += "Delete From CMR_DepositOrder where CMR_DO='" + ddlDONo.SelectedItem.ToString() + "' ; "; instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); END CATCH;"; cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnDelete.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('CMR Deposit Order Deleted Successfully'); </script> "); //txtYear.Text = ""; ddlCropyear.Enabled = false; ddlFrmDist.Enabled = ddlMillName.Enabled = ddlAgtmtNumber.Enabled = ddlDONo.Enabled = false; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } } }
protected void btnDelete_Click(object sender, EventArgs e) { if (ddlDONo.SelectedIndex <= 0) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Please Select DO Number'); </script> "); return; } decimal DOQty = 0, DORemQty = 0; for (int i = 0; i < GridView2.Rows.Count; i++) { DOQty += decimal.Parse(GridView2.Rows[i].Cells[4].Text); DORemQty += decimal.Parse(GridView2.Rows[i].Cells[5].Text); } if (DOQty != DORemQty) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('इस डिलीवरी आर्डर के विरुद्ध धान जारी किया जा चूका है, इसलिए आप इसे Delete नहीं कर सकते|'); </script> "); return; } ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); ConvertServerDate ServerDate = new ConvertServerDate(); string ConvertFromDate = ServerDate.getDate_MDY(txtDODate.Text); string ConvertToDate = ServerDate.getDate_MDY(txtDOLastDate.Text); if (txtYear.Text != "") { if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { con.Open(); string instr = ""; instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION "; instr += "Insert Into PaddyMilling_Agreement_Log(District,Dist_Manager_Name,Mill_Addr_District,Mill_Name,Mill_Operator_Name,Mill_Operator,CropYear,From_Date,To_Date,Common_Dhan,GradeA_Dhan,Total_Dhan,Agreement_ID,IP_Address,Current_DateTime,User_Agent,State,State_Code,DepositMoney,DhanLot,DhanAmount,DhanAmountType,DhanAmountDetails,Agrmt_Date,R_Arva,R_Ushna,Rem_Common_Dhan,Rem_GradeA_Dhan,Rem_Total_Dhan,Rem_DhanLot,Milling_Type,Return_CommonDhan,Return_GradeADhan,Return_TotalDhan,Return_CommonRice,Return_GradeARice,Return_TotalRice,Rejected,IsAccepted,MobileNO,AcceptedIP,AcceptedDate,DeletedDate,DeletedIP,Operation) select District,Dist_Manager_Name,Mill_Addr_District,Mill_Name,Mill_Operator_Name,Mill_Operator,CropYear,From_Date,To_Date,Common_Dhan,GradeA_Dhan,Total_Dhan,Agreement_ID,IP_Address,Current_DateTime,User_Agent,State,State_Code,DepositMoney,DhanLot,DhanAmount,DhanAmountType,DhanAmountDetails,Agrmt_Date,R_Arva,R_Ushna,Rem_Common_Dhan,Rem_GradeA_Dhan,Rem_Total_Dhan,Rem_DhanLot,Milling_Type,Return_CommonDhan,Return_GradeADhan,Return_TotalDhan,Return_CommonRice,Return_GradeARice,Return_TotalRice,Rejected,IsAccepted,MobileNO,AcceptedIP,AcceptedDate,GETDATE(),'" + GetIp + "','U' From PaddyMilling_Agreement_2017 where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ; "; instr += "Insert Into PaddyMilling_DO_Log_2017(DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,DeletedDate,DeletedIP,Operation) select DO_Number,Mill_Code,Agreement_ID,District,CropYear,From_Date,To_Date,Milling_Type,Alloted_CommonDhan,Alloted_GradeADhan,R_Arva,R_Ushna,Issue_Centre,IP_Address,Current_DateTime,User_Agent,Check_DO,DispatchDhan_IC,Return_CommonRice,Return_GradeARice,Return_TotalRice,LotOnlyNumber,Rejected,DhanLot,Branch_Code,Godown_Code,LotNumber,Rem_Alloted_CommonDhan,Rem_Alloted_GradeADhan,Rem_DhanLot,LotNo,GETDATE(),'" + GetIp + "','U' From PaddyMilling_DO_2017 where Check_DO='" + ddlDONo.SelectedItem.ToString() + "' ; "; instr += "Update PaddyMilling_Agreement_2017 Set Rem_Common_Dhan=(Rem_Common_Dhan+'" + DORemQty + "') , Rem_Total_Dhan=(Rem_Total_Dhan+'" + DORemQty + "') , Rem_DhanLot=(Rem_DhanLot+1) where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' ;"; instr += "Delete PaddyMilling_DO_2017 where Check_DO='" + ddlDONo.SelectedItem.ToString() + "' ; "; for (int i = 0; i < GridView2.Rows.Count; i++) { decimal UPDORemQty = 0; string IC = "", Godown = ""; UPDORemQty = decimal.Parse(GridView2.Rows[i].Cells[5].Text); IC = GridView2.Rows[i].Cells[6].Text; Godown = GridView2.Rows[i].Cells[7].Text; instr += "Update PaddyMapping_Godown set Rem_CommonPaddy=(Rem_CommonPaddy+" + UPDORemQty + ") where CropYear='" + txtYear.Text + "' and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' and Agreement_ID='" + ddlAgtmtNumber.SelectedValue.ToString() + "' and Godown_id='" + Godown + "'; "; } instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); END CATCH;"; cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnDelete.Enabled = false; Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Deleted Successfully'); </script> "); txtYear.Text = ""; ddlFrmDist.Enabled = ddlMillName.Enabled = ddlAgtmtNumber.Enabled = ddlDONo.Enabled = false; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Deletion Not Allow'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } }
protected void btnRecptSubmit_Click1(object sender, EventArgs e) { ClientIP objClientIP = new ClientIP(); string GetIp = (objClientIP.GETIP()); if (txtYear.Text != "") { if (Session["update"].ToString() == ViewState["update"].ToString()) { using (con = new SqlConnection(strcon)) { try { con.Open(); string instr = ""; string ChechMax = "", DCDate = "", MaxMappingNo = ""; //decimal MaxMappingNo = 0; //ChechMax = "Select Max(Mapping_No) As MaxMap From PaddyMapping_Godown Where Agreement_ID='" + ddlAgtmtNumber.SelectedItem.ToString() + "' and Mill_ID='" + ddlMillName.SelectedValue.ToString() + "' and CropYear='" + txtYear.Text + "' "; //da = new SqlDataAdapter(ChechMax, con); //ds = new DataSet(); //da.Fill(ds); //if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) //{ // MaxMappingNo = decimal.Parse(ds.Tables[0].Rows[0]["MaxMap"].ToString()); //} ChechMax = "select CONVERT(varchar(10),YEAR(GETDATE()))+CONVERT(varchar(10),MONTH(GETDATE()))+CONVERT(varchar(10),DAY(GETDATE()))+CONVERT(varchar(10),DATENAME(HH,GETDATE()))+CONVERT(varchar(10),DATENAME(MI,GETDATE()))+CONVERT(varchar(10),DATENAME(SS,GETDATE()))+CONVERT(varchar(10),DATENAME(MS,GETDATE())) As DCDate"; da = new SqlDataAdapter(ChechMax, con); ds = new DataSet(); da.Fill(ds); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DCDate = ds.Tables[0].Rows[0]["DCDate"].ToString(); MaxMappingNo = DCDate.Substring(2); } if (MaxMappingNo != "") { instr = "BEGIN TRY; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRANSACTION "; if (chkGodam.Checked == true) { for (int i = 0; i < GridView2.Rows.Count; i++) { string RemPaddy = GridView2.Rows[i].Cells[4].Text; string RemAllotedPaddy = GridView2.Rows[i].Cells[3].Text; string MappingNo = GridView2.Rows[i].Cells[6].Text; instr += "Update PaddyMapping_Godown Set Alloted_CommonPaddy='" + RemAllotedPaddy + "', Rem_CommonPaddy='" + RemPaddy + "' where Mapping_No='" + MappingNo + "' ;"; } } else { for (int i = 0; i < GridView2.Rows.Count; i++) { string RemPaddy = GridView2.Rows[i].Cells[4].Text; string RemAllotedPaddy = GridView2.Rows[i].Cells[3].Text; string MappingNo = GridView2.Rows[i].Cells[6].Text; instr += "Update PaddyMapping_Godown Set Alloted_CommonPaddy='" + RemAllotedPaddy + "', Rem_CommonPaddy='" + RemPaddy + "' where Mapping_No='" + MappingNo + "' ;"; } DataTable dt = adddetails(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { string Mapping_No = MaxMappingNo + (i + 1); instr += "Insert into PaddyMapping_Godown(District,CropYear,Mill_ID,Agreement_ID,Mapping_No,IssueCenter,Godown_id,Alloted_CommonPaddy,Alloted_GradePaddy,Rem_CommonPaddy,Rem_GradePaddy,CreatedDate,IP_Address) values('" + dt.Rows[i]["DistCode"] + "','" + txtYear.Text + "','" + ddlMillName.SelectedValue.ToString() + "','" + ddlAgtmtNumber.SelectedValue.ToString() + "','" + Mapping_No + "','" + dt.Rows[i]["ICVal"] + "','" + dt.Rows[i]["GodownVal"] + "','" + dt.Rows[i]["QuantityQtls"] + "','0','" + dt.Rows[i]["QuantityQtls"] + "','0',GETDATE(),'" + GetIp + "');"; } } } instr += "COMMIT end TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK;DECLARE @ErrorMessage NVARCHAR(4000);DECLARE @ErrorSeverity INT;DECLARE @ErrorState INT;SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity,@ErrorState ); END CATCH;"; cmd = new SqlCommand(instr, con); int count = cmd.ExecuteNonQuery(); if (count > 0) { btnRecptSubmit.Enabled = btnAdd.Enabled = false; Session["ICGBQ"] = null; ddlIssueCentre.Items.Clear(); ddlBranch.Items.Clear(); ddlGodown.Items.Clear(); Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Data Updated Successfully'); </script> "); txtYear.Text = ""; Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('!!!!Failed'); </script> "); } } else { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('Sorry, Updation Not Allow'); </script> "); } } catch (Exception ex) { Page.RegisterClientScriptBlock("mymsg1", "<script language=javascript> alert('" + ex.Message + "'); </script> "); } finally { if (con.State != ConnectionState.Closed) { con.Close(); } } } } else { Response.Redirect(Request.Url.AbsoluteUri); } } }